Create a solid line instead of single points in the plot

조회 수: 7 (최근 30일)
Christoph
Christoph 2024년 4월 24일
답변: Steven Lord 2024년 4월 24일
My Problem is I calculated curves out of 81 Data points and want to plot it as a solid line. If I plot it, the only way it shows the curve is as points, stars etc. As you can see in the picture below.
I have to do this seven times.
The code for this is:
imax is from 1 to 7 an (each curve)
N is from 1 to 81 and are my data points
The rest is calculated before but not relevant for the problem
vR=ones(imax,N);
FZA2=ones(imax,N);
vR(k,h)=(2*pi*rdyn)*(nR(k,h)/60)*3.6;
FZA2(k,h)=(T2(h,1)*i2(k)*i2E*nges)/rdyn; %in N
plot(vR(1,h),FZA2(1,h),'.b',vR(2,h),FZA2(2,h),'.r',vR(3,h),FZA2(3,h),'.g',vR(4,h),FZA2(4,h),'.c',vR(5,h),FZA2(5,h),'.y',vR(6,h),FZA2(6,h),'.m',vR(7,h),FZA2(7,h),'.b');

답변 (2개)

VBBV
VBBV 2024년 4월 24일
If the plot function is inside a loop, you could put it outside the loop as shown below, in order to plot solid line
plot(vR(1,:),FZA2(1,:),'b-',vR(2,:),FZA2(2,:),'r-',vR(3,:),FZA2(3,:),'g-', ...
vR(4,:),FZA2(4,:),'c-',vR(5,:),FZA2(5,:),'y-',vR(6,:),FZA2(6,:),'m-',vR(7,:),FZA2(7,:),'b-');
  댓글 수: 1
VBBV
VBBV 2024년 4월 24일
편집: VBBV 2024년 4월 24일
From your code, it shows that you try to plot scalars which need markers ,instead if you plot vectors, you can obtain a solid line without markers. You can also avoid, the repetition inside the plot function, by using a for or a while looop.

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


Steven Lord
Steven Lord 2024년 4월 24일
Rather than plotting individual points inside a loop (as @VBBV and I both suspect you are doing) you could pull the plot command out of the loop (as VBBV suggested previously) or you could create an animatedline before the loop and addpoints to it inside the loop.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by