Error in plot... vectors must be same length
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
N=30; %no of divisions;
l=30;
delta_x=l/N;
M(1,1)=0;
N(1,1)=1;
O(1,1)=0;
P(1,1)=100;
M(N+1,1)=0;
N(N+1,1)=1;
O(N+1,1)=0;
P(N+1,1)=100;
M(2:N,1)=1;
N(2:N,1)=-(2+0.071^2);
O(2:N,1)=1;
P(2:N,1)=0;
x(1,1)= 100;
x(N+1,1)=100;
%Thomas Algorithm
for p=2:N+1
N(p,1)=N(p,1)-(M(p,1)/N(p-1,1))*O(p-1,1);
P(p,1)=P(p,1)-(M(p,1)/N(p-1,1))*P(p-1,1);
M(p,1)=0;
end
for p=N:-1:2
x(p,1)=(P(p,1)-O(p,1)*x(p+1,1))/N(p,1);
end
plot((0:1:30),x);
grid on;
xlabel("Variation of Length (x) in (cm) ");
ylabel("Temperature in Celsius");
title("Temperature vs Variation of length (TDMA)");
hold on;
0 commentaires
Réponses (1)
KSSV
le 9 Avr 2022
These lines:
N=30; %no of divisions;
l=30;
delta_x=l/N;
M(1,1)=0;
N(1,1)=1; % <---- over writitng values of N
Why you are overwrititng the value of N? You have defined it to 30, but later you over write it to 1. So at the end, your x size is 1x2, you tried plotting it w.r.t. a vector of size 1x30 so error popped out. Modify your code.
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!