How to plot functions within a range?
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Walter Roberson
il 7 Mar 2018
0 voti
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.
Categorie
Scopri di più su Calculus in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!