How to plot functions within a range?
Mostrar comentarios más antiguos
My question is how to plot trigonometric functions within a specified range. This is the code fragment from the script
x = linspace(-2*pi, 2*pi);
y = tan(x);
dy = diff(y);
plot(x,y,x,dy);
When I run the code I receive de following error.
Error using plot
Vectors must be the same length.
Any sort of help and advice is more than welcome
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 7 de Mzo. de 2018
0 votos
You are applying diff() to a numeric array. That is defined by simple numeric differences.
If you were to use points closer and closer together then the mathematical limit as the distance approaches 0 would be the calculus differentiation. But only in the limit: numeric diff() approximates derivative half way between points.
Categorías
Más información sobre Calculus 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!