필터 지우기
필터 지우기

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
cindyawati cindyawati 2023년 5월 13일
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 2023년 5월 13일
Yes, for this you have to check the code. Please cross check again whether this is done correctly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by