Finding the highest and lowest point of a function
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi i want to ask about something, i want to solve and locate the highest and lowest points of a function using matlab gui but i dont know how to code it. The function is user defined and here is my code:
funcString = get(handles.edit1,'String');
funcHandle = str2func(['@(x)' funcString]);
x = linspace(10,-10,100);
y = funcHandle(x);
plot(handles.axes1,x,y);
please help
1 comentario
Rik
el 24 de Abr. de 2023
What have you tried?
The obvious method of min and max will only work if your linspace happens to actually return the exact correct points, so you will need something smarter. Do you have the curve fitting toolbox? Otherwise you might be stuck with fminsearch.
Respuestas (1)
Aditya Srikar
el 28 de Abr. de 2023
Hi Joe
Let X represent a list of X-coordinates of all points of a curve.
Let Y represent a list of Y-coordinates of all points of a curve.
To obtain maximum value of Y-coordinate
Y1 = max(Y)
To obtain X-coordinate of point with maximum Y-coordinate value
X1 = X(find(Y == Y1))
To obtain minimum value of Y-coordinate
Y2 = min(Y)
To obtain X-coordinate od point with minimum Y-coordinate value
X2 = X(find(Y == Y2))
Hope it helps !
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!