Find minimum y value of vectors
2 ビュー (過去 30 日間)
古いコメントを表示
The first part of the code I need to show the values of x and y vectors when t is between 0 and 10 for which I have the following code
for i=1:10;
t=i;
x = 5 + sqrt(t);
y= 2 + sin(2*t)/(t+1);
disp(['The Value for t is: ',num2str(t) , ' which gives us x as: ',num2str(x),' and y as ',num2str(y)])
end
The next task is to identify the minimum value Y vector (and the corresponding t and x values at that point). Im feeling pretty stumped as to how to find a minimum value? Any help appreciated
0 件のコメント
回答 (3 件)
Star Strider
2016 年 10 月 17 日
Use the min function with both outputs.
I leave the rest to you.
0 件のコメント
Andriy Kavetsky
2016 年 10 月 17 日
If you write for i=1:10; t=i, then you would'nt get vector because t=10, maybe you should write t(i)=i for creating an vector and y should be like y= 2 + sin(2.*t)./(t+1);.To find minimum y use [ymin,ind]=min(y); ymin-minimum value and ind its index, so display t(ind) and x(ind), they will correspond to y index.
0 件のコメント
Image Analyst
2016 年 10 月 17 日
Rebecca, since t = i, which goes from 1 to 10, t will ALWAYS be between 0 and 10 with your code - how could it not be? So you need to display ALL x and y. To find the min of a current value and a previous min value, you can do
minValue = min([minValue, currentValue]);
Adapt as needed.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!