- You overwrite y when computing the functional; if want to keep it, write z=... instead.
- The idiom min(min()) can be written as either zmin=min(z(:)): or if have release R2018b or later as zmin=min(z,'all');
find minimum value of a two-variable equation on an interval.
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I searched a lot about this question but I still have a trouble in deleting the . when I run the code,
[x y] = meshgrid(1:0.01:2*pi,1:0.01:2*pi);
y = 4*x.^2 + 5*y.^2;
min(min(y));
I dont want copy the equation y every time when I am doing an experiment that have a lot of data.
Thanks!
2 个评论
dpb
2020-2-25
Not sure what the real question is...couple comments:
If those don't match what looking for, explain further...
采纳的回答
dpb
2020-2-25
"...is there anyway I can delet[e] the dot but the equation can still work?"
Ah! Indeed I didn't follow along the nub of the question.
Yes, but not with vectorized inputs; you'd then have to either write the loop explicitly or use arrayfun to process the inputs.
The "dot" operators are mandatory to evaluate the elements of the input arrays as element-by-element operations; otherwise they will be matrix operators which is not what is wanted/needed here.
However, MATLAB is thinking about that for you, already! :) Don't try to swim upstream, instead of trying to evaluate the non-vectorized version, vectorize it instead.
Need more information on the manner in which this "experiment process" is implemented; I'd guess there may be a way to automate the transfer to (say) a text file which could be read into a string which could subsequently be modified as needed by inserting the dot operators via vectorize. The string could then be converted to the functional with str2func
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!