error using plot vectors must be the same length
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Heya :)
am 1 Okt. 2020
Beantwortet: Asad (Mehrzad) Khoddam
am 1 Okt. 2020
Why i am getting this error in plot (Data, hx,) and how to fix it?
This is my code
for i=2:test_points
x_rec(i)=c1+c2*x_rec(i-1)+c3*hx(i-1)+c4*x_rec(i-1)*hx(i-1)+c5*x_rec(i-1)^2+c6*hx(i-1)^2+c7*x_rec(i-1)^2*hx(i-1)^2;
hx(i)=d1+d2*x_rec(i-1)+d3*hx(i-1)+d4*x_rec(i-1)*hx(i-1)+d5*x_rec(i-1)^2+d6*hx(i-1)^2+d7*x_rec(i-1)^2*hx(i-1)^2;
x_real(i)=x(start_point+i-1);
error=error+(x_rec(i)-x_real(i))^2;
DN=DN+x_real(i)^2;
end
Error_x(count)=sqrt(error)/sqrt(DN);
end
figure
hold on
plot (Data,Error_x,'s-r')
plot (Data,hx,'s-b')
This is the error
Vectors must be the same length.
Error in PE_HT (line 136)
plot (Data,hx,'s-b')
2 Kommentare
KSSV
am 1 Okt. 2020
The error is clear....diemnsions of Data and hx are not same. Check their sizes.
Akzeptierte Antwort
Asad (Mehrzad) Khoddam
am 1 Okt. 2020
try to use this line of code inside the loop. For now, the code returns a single point for error;
for i=2:test_points
x_rec(i)=c1+c2*x_rec(i-1)+c3*hx(i-1)+c4*x_rec(i-1)*hx(i-1)+c5*x_rec(i-1)^2+c6*hx(i-1)^2+c7*x_rec(i-1)^2*hx(i-1)^2;
hx(i)=d1+d2*x_rec(i-1)+d3*hx(i-1)+d4*x_rec(i-1)*hx(i-1)+d5*x_rec(i-1)^2+d6*hx(i-1)^2+d7*x_rec(i-1)^2*hx(i-1)^2;
x_real(i)=x(start_point+i-1);
error=error+(x_rec(i)-x_real(i))^2;
DN=DN+x_real(i)^2;
Error_x(i)=sqrt(error)/sqrt(DN);
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!