I want to plot this code, but my value show zero and the graph nothing to show. How to fix it
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
cindyawati cindyawati
el 13 de Mayo de 2023
Comentada: KALYAN ACHARJYA
el 13 de Mayo de 2023
clc;clear;
%input parameter
delta=50;
K1= 10^-4;
Ko=0.1;
n=3;
Oa=10;
Pa=100;
mu_1=10^-3;
K2=5*10^-4;
K3=10^-4;
gamma=75;
K=100;
%input initial condition
M1(1)=10;
M2(1)=0;
M3(1)=0;
%input for time
t(1)=0;
h=0.01; %time interval
dt=0:h:100; %time span
%input empty array
t=zeros(length(dt),1); %empty array for t
M1=zeros(length(dt),1); %empty array for M1
M2=zeros(length(dt),1); %empty array for M2
M3=zeros(length(dt),1); %empty array for M3
K=zeros(length(n-1),1);
for j= 1:length(dt)
t(j+1)=t(j)+h*j;
M11=M1(j)+1./(1+exp(-dt));
end
for i=1:length(n-1)
K(i+1)=K(i)+n*i;
end
for j = 1:length(dt(j))
M1(j+1) = M1(j)+t(j)*[delta*M1(j)*[1-(M1(j)/gamma)]-2*K1*M1(j)*M1(j)-M1(j)*(K(i+1).*M1(j))-(Oa-n)*K3*M1(j)*M3(j)-(Pa-Oa)*Ko*M1(j)*10-(mu_1*M1(j))]
end
figure
plot (dt,M1(j+1),'r','Linewidth',3)
xlabel('time')
ylabel('M1')
4 comentarios
Torsten
el 13 de Mayo de 2023
I suggest
for you.
It's a free MATLAB online course where you can learn the basics of the language.
Respuesta aceptada
KALYAN ACHARJYA
el 13 de Mayo de 2023
Editada: KALYAN ACHARJYA
el 13 de Mayo de 2023
M1 must be vector, however in the code plot M1(j+1) is a scalar (Single value)
plot (dt,M1,'r','Linewidth',3);
To get the desirable plot, please make modifications on code.
2 comentarios
KALYAN ACHARJYA
el 13 de Mayo de 2023
Yes, for this you have to check the code. Please cross check again whether this is done correctly.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!