subscript indices must either be real positive integers or logicals help line u1(0)=2
    5 views (last 30 days)
  
       Show older comments
    
    Bui Thien Phuc
 on 6 Apr 2019
  
    
    
    
    
    Answered: Star Strider
      
      
 on 6 Apr 2019
            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);
0 Comments
Accepted Answer
  Star Strider
      
      
 on 6 Apr 2019
        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 Comments
More Answers (0)
See Also
Categories
				Find more on Logical in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
