Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti

Accedi per commentare.

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 13 Mag 2023
Modificato: KALYAN ACHARJYA il 13 Mag 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 Commenti
cindyawati cindyawati
cindyawati cindyawati il 13 Mag 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')
KALYAN ACHARJYA
KALYAN ACHARJYA il 13 Mag 2023
Yes, for this you have to check the code. Please cross check again whether this is done correctly.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by