Stairs Command MATLAB Ends
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Is it possible to put a circle at the end of the stairs function? If the value is 0 and each end, one cannot see where it starts.
採用された回答
Dear T,
I think you can do as follows (If i understood correctly)
figure
X = linspace(0,4*pi,40);
Y = sin(X);
stairs(X, Y), hold on
plot(X(end), Y(end), 'ro', 'linewidth', 2)
Or maybe you can use different color for next stairs to see difference between two series.
I hope it helps. Good luck!
16 件のコメント
T
2013 年 10 月 22 日
Suppose I want to do the same thing with:
plotyy(x1,y1,x2,y2,@stairs, @plot);
How would I be able to modify it in this case?
sixwwwwww
2013 年 10 月 22 日
In this case you can do like this:
X1 = linspace(0,4*pi,40);
Y1 = sin(X1);
X2 = linspace(4*pi, 8*pi, 40);
Y2 = sin(X2);
x = [X1(end) X2(end)];
y = [Y1(end) Y2(end)];
plotyy(X1, Y1, X2, Y2, @stairs, @plot), hold on
plot(x, y, 'ro', 'linewidth', 2)
Good luck!
T
2013 年 10 月 23 日
Suppose instead the red circles are on the stairs function:
X1 = linspace(0,4*pi,40);
Y1 = sin(X1);
X2 = linspace(4*pi, 8*pi, 40);
Y2 = sin(X2);
x = [X1 X2];
y = [Y1 Y2];
plotyy(X1, Y1, X2, Y2, @stairs, @plot), hold on
plot(x, y, 'ro', 'linewidth', 2)
I have an edit box that moves the stairs function to the right. My issue is that it keeps duplicating the plot. I only want it to appear once.
I tried experimenting with a check box but the issue still arises.
sixwwwwww
2013 年 10 月 23 日
Can you show me your full code?
T
2013 年 10 月 23 日
The issue arises with these two lines:
hold on
plot(x, y, 'ro', 'linewidth', 2)
The fact that, once plotted, it remains on the figure.
I need to find a way to update it so that it plots only after translation.
sixwwwwww
2013 年 10 月 23 日
In this case you need to update these values:
x = [X1(end) X2(end)];
y = [Y1(end) Y2(end)];
before using
hold on
plot(x, y, 'ro', 'linewidth', 2)
then it will work again. Can you check it now?
T
2013 年 10 月 23 日
That's right. But after I translate it to the right, the previous plot will remain and it will duplicate it again, but to the right. So now you have two plots with red circles. I just want the later one.
sixwwwwww
2013 年 10 月 23 日
x = [X2(end)];
y = [Y2(end)];
here X2(end) and Y2(end) are the values for the sifted plot. Then use
hold on
plot(x, y, 'ro', 'linewidth', 2)
It will just plot one red circle at the end of the second graph which you need(if I understood correctly)
T
2013 年 10 月 23 日
I guess we should forget this idea of having a second function.
I think I should stick with the checkbox feature.
Suppose I apply the following:
x = [X2];
y = [Y2];
hold on
plot(x, y, 'ro', 'linewidth', 2)
If on produces the above, how would I remove it if I unchecked the checkbox?
sixwwwwww
2013 年 10 月 23 日
For this purpose you can clear the graphic object using
clf
when state of checkbox is changed and then you can re-plot the graph without red circles i.e. don't use
hold on
plot(x, y, 'ro', 'linewidth', 2)
after plotting the original graph.
T
2013 年 10 月 23 日
clf will clear my entire GUI so that is not an option for me.
Azzi Abdelmalek
2013 年 10 月 23 日
編集済み: Azzi Abdelmalek
2013 年 10 月 23 日
You can use
cla
T
2013 年 10 月 23 日
This is close.
hold on
cla
plot(x, y, 'ro', 'linewidth', 2)
Will not plot the stairs function but only the red circles. When I shift, it only plot once which is what I want but the stairs is missing.
sixwwwwww
2013 年 10 月 23 日
use
stairs(x, y)
to plot stairs and then if you again need red circle at the end. Again use
hold on
plot(x(end), y(end), 'ro', 'linewidth', 2)
The logic remains the same always that every time you want to over write the plot using state of checkbox. Use the following commands in the sequence:
cla
stairs(x, y)
hold on
plot(x(end), y(end), 'ro', 'linewidth', 2)
T
2013 年 10 月 23 日
Now the issue that arises is not only does unchecking the box off removes the stairs function, but there is also the issue of changing the axes when using the plot.
Is there a better alternative?
sixwwwwww
2013 年 10 月 24 日
How you want to change the axis when you plot? Can you provide some screen shots what you need and what are you getting right now?
その他の回答 (1 件)
Azzi Abdelmalek
2013 年 10 月 18 日
編集済み: Azzi Abdelmalek
2013 年 10 月 18 日
x=1:10
y=[0 1 0 1 0 1 0 1 0 1]
stairs(x,y,'k')
hold on
scatter(x,y,'or','linewidth',2)
%you can also change ylim
ylim([0 1.5])
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
タグ
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
