Fixing Error using plot Invalid first data argument - new to matlab
Mostrar comentarios más antiguos
I am trying to plot the function y=cos(x)*sin(x^2) and its derivative from -pi to pi. Here is my code. Why do I keep getting errors? At first I tried linespace but that didn't work. What do I do? I am new to matlab.
x=-pi:100:pi;
y=cos(x)*sin(x^2);
dy=2*x*cos(x^2)*(cos(x))-sin(x^2)*sin(x);
clf
hold on
plot(x,y, 'r', 'LineWidth', 3);
xlabel('x');
ylabel('y');
hold on
grid on
plot(x,dy, 'b', 'o--', 'LineWidth', 1);
title(['Graph of y=sin(x^2)cos(x) and y' by Jay Gersten'])
legend('cos(x)*sin(x.^2)','2*x*cos(x.^2)*cos(x)-sin(x.^2)*sin(x)')
dbstop if error
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Annotations 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!