Error using plot Vectors must be the same length.
이전 댓글 표시
I have a problem about using plot... Why i giving a problem? plot(x1,y1,color1,x2,y2,color2...) it's look like true but no its not true. HELP!!!
deger = app.Switch.Value;
a=app.genlik_edit.Value;
b=app.frekans_edit.Value;
c=app.direnc_edit.Value;
f=1/b;
t1=linspace(0,f,256);
t3=linspace(f/2,f,256);
v=a*sin(2*pi*b*t1);
v1=c*sin(2*pi*b*t1);
rect_v = v > 0;
anrect_v = v<0;
rect_v1 = v1 > 0;
l=v*0;
if (deger=="Yarım dalga doğrultucu")
plot(app.UIAxes1,t1(rect_v),v(rect_v),'color',[1,0,0],t3,l,'color',[1,0,0],t1(anrect_v),v(anrect_v),'color',[0,0,1]);
plot(app.UIAxes2,t1(rect_v),v1(rect_v),t3,l,"Color",[0,1,0]);
else
plot(app.UIAxes1,t1(anrect_v),v(anrect_v),t1,abs(v));
plot(app.UIAxes2,t1,abs(v1),"Color",[0,1,0]);
end
답변 (1개)
Cris LaPierre
2021년 5월 29일
0 개 추천
The error message is telling you what the problem is - you are trying to plot using a different number of x and y points. In this case, plot doesn't know what to do so it throws an error. It would be helpful to know which line in your code is causing the error.
I suspect either t3 and l don't have the same number of points, or t1 and abs(v1) don't.
댓글 수: 3
Canberk Utar
2021년 5월 29일
Canberk Utar
2021년 5월 29일
Cris LaPierre
2021년 5월 29일
The error is very clear: when using plot, your x and y vectors must be the same length.
As I suspected, it appears t3 and l do not have the same number of points. These serve as the x and y coordinate pairs, so must be the same length in order to create the coordinate points.
카테고리
도움말 센터 및 File 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!