# Having problem when using the Matlab APi

**URL:** <https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704>\
**Category:** New to AMPL\
**Tags:** general, solvers\
**Created:** [August 29, 2023, 1:24pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704 "2023-08-29T13:24:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HammerDog](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@HammerDog](https://discuss.ampl.com/u/HammerDog)\
**Post date:** [August 29, 2023, 1:24pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/1 "2023-08-29T13:24:40Z")

</div>

I’m having problems when following the instructions in the Initial Setup section of the MATLAB API document([AMPL MATLAB API — AMPL API 2.1.4 documentation](https://portal.ampl.com/docs/api/latest/matlab/index.html)). After running setupOnce, I go on to the firstExample function without specifying solver. Then I got the following result.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/ampl/original/1X/b0de372559ccea5da9663fa4488b5112f0769ffd.png)  
Then, after I request the MINOS and update my license, I specified the solver minos like firstExample(minos), and I got  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/ampl/original/1X/048479c23abb8168b57cab5a90e081fbdec0125f.png)  
I tried to use another solver IPOPT, but it seemed that IPOPT cannot be invoked.  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/ampl/original/1X/d531fdc55792656dc61642e1366795aa0f9fdf55.png)  
I don’t know where I went wrong, could you please tell me how to deal with this problem? Thank you very much.

---

<div class="post-metadata">

**Author:** ![fdabrandao](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/fdabrandao/32/63_2.png) [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Post date:** [August 29, 2023, 1:32pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/2 "2023-08-29T13:32:51Z")

</div>

Hi @HammerDog,

You need to pass the solver name as a string (e.g., `firstExample("ipopt")`), or modify the MATLAB script to set the solver with `ampl.setOption("solver", "ipopt");`.

---

<div class="post-metadata">

**Author:** ![HammerDog](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@HammerDog](https://discuss.ampl.com/u/HammerDog)\
**Post date:** [August 29, 2023, 1:56pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/3 "2023-08-29T13:56:18Z")

</div>

Your advice is very helpful, I have already solved my problem, thank you very much!

---

<div class="post-metadata">

**Author:** ![liangzilu\_liangzilu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/liangzilu_liangzilu/32/408_2.png) [@liangzilu\_liangzilu](https://discuss.ampl.com/u/liangzilu_liangzilu)\
**Post date:** [September 9, 2023, 12:43pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/4 "2023-09-09T12:43:28Z")

</div>

How to use matlab and ampl together

 ![image](https://us1.discourse-cdn.com/flex019/uploads/ampl/original/1X/f0060fb03d208771ea506540c575ccc719dac736.png)

---

<div class="post-metadata">

**Author:** ![HammerDog](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@HammerDog](https://discuss.ampl.com/u/HammerDog)\
**Post date:** [September 9, 2023, 1:41pm UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/5 "2023-09-09T13:41:19Z")

</div>

Every time you use this api, run setupOnce.m once in the folder where the setupOnce file is located. So you may need to set the current path to this folder. I’m a beginner too, I hope my advice is useful.

---

<div class="post-metadata">

**Author:** ![liangzilu\_liangzilu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/liangzilu_liangzilu/32/408_2.png) [@liangzilu\_liangzilu](https://discuss.ampl.com/u/liangzilu_liangzilu)\
**Post date:** [September 10, 2023, 2:48am UTC](https://discuss.ampl.com/t/having-problem-when-using-the-matlab-api/704/6 "2023-09-10T02:48:13Z")

</div>

I’m a beginner too,thanks
