Plotting error "Vectors must be the same length"

2 vues (au cours des 30 derniers jours)
omar rakgha
omar rakgha le 31 Mar 2022
Commenté : omar rakgha le 31 Mar 2022
Hi,
I am trying to plot each j output for y1 in a seperate subplot but i keep getting "Error using plot, Vectors must be the same length"
Can someone help, ive tried everything but nothing seems to fix this.
clc; clear all; format compact;close all
% Numerical Solution
A = 2; % m2
Kc = linspace(1,5,5); % m2/min
Ti = 0.1; % min
y2(1,[1 2 3 4 5]) = 2;
y1(1,[1 2 3 4 5]) = 0;
Ntime = 1000;
DeltaT = 50/Ntime;
t(1) = 0;
y2(1,[1 2 3 4 5]) = 2;
y1(1,[1 2 3 4 5]) = 0;
for j = 1:5
for n = 1:Ntime
y2(n+1,j) = y2(n,j)-((1/A)*(Kc(j)*y2(n,j)+Kc(j)*y1(n,j)/Ti)*DeltaT);
y1(n+1,j) = y1(n,j)+y2(n,j)*DeltaT;
t(n+1,j) = t(n)+DeltaT;
end
subplot(1,5,j)
plot(t,y1)
end

Réponse acceptée

VBBV
VBBV le 31 Mar 2022
t(n+1)=t(n)+DeltaT;
Change this line to above
  2 commentaires
VBBV
VBBV le 31 Mar 2022
subplot(5,1,j)
Do this for better display of graphs
omar rakgha
omar rakgha le 31 Mar 2022
thank you so much!!!!!!!!!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by