If statement in Matlab involving time variable

  • MATLAB
  • Thread starter Srodrigu
  • Start date
  • #1
1
0
Im Having trouble writing an if statement with the time variable of the ode45 function.
I don't know if i need to create a new variable, which is not what i want, but just to create and if statement with the t variable from ODEs.

Hope someone knows how to solve this problem

Thank you
 

Answers and Replies

  • #2
492
1
I'm not sure what your code looks like but going from the example from matlab:
[T,Y] = ode45(odefun,tspan,y0)

Then you want an if statement based on T? Then you probably need to have the if statement inside of a for loop to go through each value of T, like:

for i = 1:length(T)
if T(i) == value
statement
end
end
 

Related Threads on If statement in Matlab involving time variable

  • Last Post
Replies
1
Views
3K
Replies
2
Views
6K
Replies
2
Views
3K
Replies
3
Views
1K
Replies
1
Views
2K
Replies
6
Views
7K
Replies
1
Views
5K
Replies
3
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Top