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.
채택된 답변
0 개 추천
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일
0 개 추천
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에 대해 자세히 알아보기
태그
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
