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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2023-5-13
编辑:KALYAN ACHARJYA 2023-5-13
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 个评论
cindyawati cindyawati
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')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by