Code not working on my computer, but same file working on my schools computer

1 view (last 30 days)
'optimoptions' requires Optimization Toolbox.
Error in pro1_maingrad (line 14)
options = optimoptions('fmincon','Display','iter','Algorithm','active-set','TolFun',1e-8,'TolCon',1e-7,'SpecifyObjectiveGradient',true,'SpecifyConstraintGradient',true);
[xstar,fstar] = fmincon(@(x)pro1_objgrad(x), x0, [], [], [], [], lb, ub, ...
@(x)pro1_consgrad(x),options);
Above the part of the code I am using for a project. The University and I are both using R2022a, and it I emailed the entire folder of files for this project so I could work on it at home without having to remote in and deal with lag and internet stuff. I remoted in and the same exact code works on their comnputer but not mine. I copied the entire code and pasted it on my local code and it still did not work but still does on the schools computer. Do I have to download soemthing else? Like Simulink or anything else? I do not understand why the code would work on one computer and won't when it was copied to mine.

Answers (1)

Dyuman Joshi
Dyuman Joshi on 28 Mar 2023
Edited: Dyuman Joshi on 28 Mar 2023
As the error states, 'optimoptions' requires Optimization Toolbox. The school's PC has the Optimation Toolbox downloaded, where as your PC does not.
If you have the access to the Optimization Toolbox, you need to download it first. And as your school has access to it, you should have it as well.
To download the toolbox, Click on 'Add-ons' option on Home tab of the toolstrip, which opens a window 'Add-on explorer', type the Toolbox name and download it.

Categories

Find more on Downloads in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!