Plotting error "Vectors must be the same length"

2 visualizaciones (últimos 30 días)
omar rakgha
omar rakgha el 31 de Mzo. de 2022
Comentada: omar rakgha el 31 de Mzo. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by