subscript indices must either be real positive integers or logicals help line u1(0)=2

4 ビュー (過去 30 日間)
clear
close all;
h = 0.5;
N = 10;
u1(0)= 2 ;
u2(0)= 3 ;
t(0) = 2;
for n=0:10
u1(n+1)=u1(n) +h*u2(n);
u2(n+1)=u2(n) +h*(4*exp(0.8*t(n))-(0.5)*u1(n));
t(n+1)= t(n) + h ;
end
plot(u1,u2);

採用された回答

Star Strider
Star Strider 2019 年 4 月 6 日
Positive integers are integers greater than 0.
This works:
h = 0.5;
N = 10;
u1(1)= 2 ;
u2(1)= 3 ;
t(1) = 2;
for n=1:10
u1(n+1)=u1(n) +h*u2(n);
u2(n+1)=u2(n) +h*(4*exp(0.8*t(n))-(0.5)*u1(n));
t(n+1)= t(n) + h ;
end
plot(u1,u2);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by