Says "error using plot, vectors must be the same length"

7 Ansichten (letzte 30 Tage)
Evan Skaer
Evan Skaer am 20 Okt. 2021
Bearbeitet: Scott MacKenzie am 20 Okt. 2021
x1=linspace(0,8.*pi,50)
y1=exp(-0.1.*x1).*cos(5.*x1)
xx1=linspace(0,8.*pi,1000)
x2=linspace(-1,1)
yy1=exp(-0.1.*x2).*cos(5.*x2)
x3=linspace(-4,4)
y2=sinh(5.*x3)
y3=0.5+2.*cos(0.5.*pi.*x3)/pi-2.*cos(1.5.*pi.*x3)/(3.*pi)+2.*cos(2.5.*pi.*x3)/(5.*pi)
x4=linspace(-4,4)
y4=y3-2.*cos(3.5.*pi.*x4)/(7.*pi)+2.*cos(4.5.*pi.*x4)/(9.*pi)
plot(x1,y1)
plot(xx1,yy1)
plot(x2,y2)
plot(x3,y3)
plot(x4,y4)

Akzeptierte Antwort

Scott MacKenzie
Scott MacKenzie am 20 Okt. 2021
Bearbeitet: Scott MacKenzie am 20 Okt. 2021
Just a simple mistake. Change the 3rd line to
xx1=linspace(0,8.*pi,100);
Or, for higher resolution, change all the linspace functions to 1000 points:
x1=linspace(0,8.*pi,50);
y1=exp(-0.1.*x1).*cos(5.*x1);
xx1=linspace(0,8.*pi,1000) ;
x2=linspace(-1,1,1000);
yy1=exp(-0.1.*x2).*cos(5.*x2);
x3=linspace(-4,4,1000);
y2=sinh(5.*x3);
y3=0.5+2.*cos(0.5.*pi.*x3)/pi-2.*cos(1.5.*pi.*x3)/(3.*pi)+2.*cos(2.5.*pi.*x3)/(5.*pi);
x4=linspace(-4,4,1000);
y4=y3-2.*cos(3.5.*pi.*x4)/(7.*pi)+2.*cos(4.5.*pi.*x4)/(9.*pi);
plot(x1,y1)
plot(xx1,yy1)
plot(x2,y2)
plot(x3,y3)
plot(x4,y4)

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by