필터 지우기
필터 지우기

Why is the line in my figure not showing up?

조회 수: 1 (최근 30일)
Shay Ang
Shay Ang 2018년 12월 21일
댓글: Shay Ang 2018년 12월 21일
I have multiple plots in same axes so i want to have 2 separate lines connecting the plots respectively. However my line is not showing eventhough my x and 0 marker shows up. What is the problem in my linespec?
for i=1:20;
%TR1 is my output 1 and TY is my output 2 %
plot(i,TR1(i),'-rx',i,TY(i),'-bo','LineWidth',2)
if i == 1
hold on
end
end
hold off
Here is the figure i get
P/S: my matlab version is R2018a

채택된 답변

Mark Sherstan
Mark Sherstan 2018년 12월 21일
Create the plot after your loop (or dont use a loop at all) as so:
... end
figure(1))
x = 1:length(TR1);
plot(x,TR1,'-rx',x,TY,'-bo','LineWidth',2)
  댓글 수: 1
Shay Ang
Shay Ang 2018년 12월 21일
Thank you, this syntax works on my codes!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 12월 21일
Each call to plot produces new primitive line objects. Different primitive line objects do not join together .
You are only plotting one point at a time so nothing you plot will join with anything else .
No loop.
plot(1:20, TR1(1:20), .......)
  댓글 수: 1
Shay Ang
Shay Ang 2018년 12월 21일
Thank you, this syntax works on my codes!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by