필터 지우기
필터 지우기

Hello, I want to make function Runge-Kutta orde 4 with equation depend on time, but in MATLAB i get some error

조회 수: 2 (최근 30일)
I want to use this equation with runge-kutta orde 4
function M1 =fRK4M1(M1)
%M1 =M1(j)+1./(1+exp(-T(j)));
m1 = (50*M1(j+1)*(1-(M1(j+1)/75))-2*(10^-4)*M1(j+1)*M1(j+1)-M1(j+1)*((5*10^-4).*M2(j+1))-((10-3)*(10^-4)*M1(j+1)*M3(j+1))-((100-10)*0.1*M1(j+1)*O(j+1))-((10^-3)*M1(j+1)));
M1 = dt *m1;
end

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 5월 19일
You have not defined j, so in MATLAB, by default that letter is used to create complex numbers. As the error message states, your index must be positive integers.
j+1
ans = 1.0000 + 1.0000i
a=1:5;
a(j+1)
Array indices must be positive integers or logical values.
  댓글 수: 2
cindyawati cindyawati
cindyawati cindyawati 2023년 5월 20일
편집: Cris LaPierre 2023년 5월 20일
Thank you for your response @Cris LaPierre. So, I must using looping like this? Because j is depend on time
t(1)=0;
dt=0.01; %time interval
t=0:dt:100; %time span
for j = 1:length((t)-1)
T(j+1)=T(j)+dt;
M1 =M1(j)+1./(1+exp(-T(j)));
end
Unrecognized function or variable 'T'.
Cris LaPierre
Cris LaPierre 2023년 5월 20일
Keep in mind that MATLAB is case sensitive. T and t are different variables.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by