フィルターのクリア

what is the difference between hold and plot of two curves in the same figure ?

4 ビュー (過去 30 日間)
diadalina
diadalina 2017 年 12 月 12 日
コメント済み: diadalina 2017 年 12 月 12 日
i want to plot cos(x) and sin(x) in the same figure, i have two ways :
i can write for example :
X=0:pi,
Y=cos(X);
Z=sin(X);
Plot(X,Y,X,Z)
or the second way :
X=0:pi;
Y=cos(X);
Z=sin(Z);
Plot(X,Y)
Hold on
Plot(X,Z)
what is the difference between these two ways ?

採用された回答

Honglei Chen
Honglei Chen 2017 年 12 月 12 日
If that's all you need, for the practical purpose, there isn't much difference. However, the internal settings in the two figures are different. For example, say you have another vector
W = cos(2*X);
and you want to plot it using
plot(X,W)
In the hold case, the new line will be added to the figure while in the other case, the axes will be cleared and the new plot contains only the new line.
HTH
  3 件のコメント
Honglei Chen
Honglei Chen 2017 年 12 月 12 日
Isn't one of them has 3 curves and the other only 2?
diadalina
diadalina 2017 年 12 月 12 日
no, they have 3 curves,i want to know the difference when i use plot and when i use hold on ?

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by