how to make reference to a line in matlab?
1 次查看(过去 30 天)
显示 更早的评论
can you make a reference to a certain line in MATLAB that will allow you to use it in a loop?
I am trying to use multiple linear equality constraints for fmincon within the loop.
1 个评论
回答(1 个)
the cyclist
2014-5-30
Assuming you mean a GOTO statement, as Image Analyst mentions, then no. But, there are some tricks you can do to effectively define two different constraints in one function. For example, you can encode
fun = @(x,N) ((N==1)*x + (N==2)*x.^2)
so that if you pass N==1, then the function is
fun = x
and if you pass N==2, then it is
fun = x.^2
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!