a basic question for a beginner
Show older comments
hello...I am starting learning Matlab by myself. there were some commands I could't understand and will be grateful if you answer me ASAP. I got the additional code (added as jpg file):
clc
close all
x=(1:0.1:10);
y=(x.*sin(x))./exp(x);
Ymin=min(y)
Xmin=x(y==Ymin)
plot (x,y);
hold on
plot (x,Ymin*(x==x),'r--');
plot (Xmin,Ymin,'*g');
- I have a problem to understand why Xmin=x(y==Ymin) makes the software to find the appropriate x value to the minimum Y value. According to what I learned the operation of == should be implemented on the same size subjecs, eg. scalar==scalar or vector==vector, what isn't the case here (vector==scalar). In addition the outcome of the above operation should be 0/1 - so I can't understand how this outcome represents the desired index (which is 32).
- I can't understand from the syntax why the command plot(x,Ymin*(x==x),'r--'); makes the software draw a horizontal line y=Ymax. I specially can't understand what the mid-term Ymin*(x==x) mean.
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification 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!