フィルターのクリア

How to plot functions within a range?

1 回表示 (過去 30 日間)
Jose Ignacio Del Valle Bustillo
Jose Ignacio Del Valle Bustillo 2018 年 3 月 4 日
回答済み: Walter Roberson 2018 年 3 月 7 日
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

採用された回答

Sujit Muduli
Sujit Muduli 2018 年 3 月 7 日
編集済み: Sujit Muduli 2018 年 3 月 7 日
Hi Jose,
It is clear from the error that there are mismatches in the size of the arguments that you have provided to plot function. I checked the size of dy is 99 where rest are 100.
I don't know what is your exact use case here, but you may modify your logic a bit to work around this error by making length(dy) = 100.
Here is the documentation link for plot function which you may find useful, https://in.mathworks.com/help/matlab/ref/plot.html
Thanks,
Sujit
  1 件のコメント
Jose Ignacio Del Valle Bustillo
Jose Ignacio Del Valle Bustillo 2018 年 3 月 7 日
Thank you, Sujit for your help its work inglés fine now

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 7 日
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.

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by