cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Minimizing within a loop

aclark-3
1-Visitor

Minimizing within a loop

Hello.

Here is a simple example of a much larger program. I want to use an index "m", which ranges from say 0 to 5, and for each value of m do a minimization.

The program works fine if I insert a specific value of m, but won't work if I allow m to range.

Thanks, Al

3 REPLIES 3
Werner_E
25-Diamond I
(To:aclark-3)

Maybe something like this. Not sure what kind of plot you had in mind.

looks good.

I guess I was supposed to put the m range at the end rather than the beginning.

Thanks, Al

Werner_E
25-Diamond I
(To:aclark-3)

> I guess I was supposed to put the m range at the end rather than the beginning.

...and add "m" as second argument of function y. Keep in mind that in this case because of the way minimize works the order of the arguments matters.

Its always a good idea to write the solve block for a single scalar, then turn it into a function of that value and later call it with a range, or, even better and more reliable, with a vector as argument (you may need vectorization),

Announcements

Top Tags