필터 지우기
필터 지우기

Find minimum y value of vectors

조회 수: 1 (최근 30일)
Rebecca Scott
Rebecca Scott 2016년 10월 17일
답변: Image Analyst 2016년 10월 17일
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

답변 (3개)

Star Strider
Star Strider 2016년 10월 17일
Use the min function with both outputs.
I leave the rest to you.

Andriy Kavetsky
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.

Image Analyst
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.

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by