I want to plot this code, but my value show zero and the graph nothing to show. How to fix it

1 view (last 30 days)
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
M1 = 10001×1
0 0 0 0 0 0 0 0 0 0
figure
plot (dt,M1(j+1),'r','Linewidth',3)
xlabel('time')
ylabel('M1')
  4 Comments

Sign in to comment.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 13 May 2023
Edited: KALYAN ACHARJYA on 13 May 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 Comments
cindyawati cindyawati
cindyawati cindyawati on 13 May 2023
If i change the code, the plot show like this, but i want to get like sigmoid graph
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
M1 = 10001×1
0 0 0 0 0 0 0 0 0 0
figure
plot (dt,M1,'r','Linewidth',3)
xlabel('time')
ylabel('M1')

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!