help me to find max :((
Mostrar comentarios más antiguos
syms x;
f(x) = (2.*x-1).*sin(pi.*x);
xMin = -2; xMax = 1; stepSize = 0.01;
for i=1:5
y=diff(f(x),i);
[val,idx] = max(y) ;%Error using sym/max (line 101)
%Input arguments must be convertible to floating-point numbers.
eval(val)
end
help me fix it plz
2 comentarios
Image Analyst
el 23 de Dic. de 2018
Editada: Image Analyst
el 23 de Dic. de 2018
You're using a symbolic x but trying to find the max numerically. Don't use syms. Use linspace to define a range for x, then use max(y), not a for loop, to find the first max. What is your desired range for x?\
x = linspace(-15, 15, 1000)
fx = (2.*x-1).*sin(pi.*x);
plot(x, fx, 'b-');
grid on;
xlabel('x', 'FontSize', fontSize);
ylabel('f(x)', 'FontSize', fontSize)

If you want the max of the derivative, why not take the analytical derivative (by the formula) of the function and find the max of that?
Phuc Nguyen Quy
el 23 de Dic. de 2018
Editada: Phuc Nguyen Quy
el 23 de Dic. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!