- 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.
3 views (last 30 days)
Show older comments
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 Comments
dpb
on 25 Feb 2020
Not sure what the real question is...couple comments:
If those don't match what looking for, explain further...
Accepted Answer
dpb
on 25 Feb 2020
"...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 Comments
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!