MATLAB, how to input step functions.

Click For Summary
SUMMARY

The discussion focuses on implementing step functions in MATLAB to solve the ordinary differential equation (ODE) y' = -a*y + u(t-1) - u(t-3). Users share methods for defining the unit step function using conditional statements. Specifically, the Heaviside function is suggested as a potential solution for simplifying the implementation. The conversation highlights the need for combining multiple conditional statements into a single .m file to accurately represent the step function behavior.

PREREQUISITES
  • Basic understanding of MATLAB programming
  • Familiarity with ordinary differential equations (ODEs)
  • Knowledge of conditional statements in programming
  • Understanding of the Heaviside step function
NEXT STEPS
  • Research the MATLAB Heaviside function for step function implementation
  • Learn how to create and use .m files in MATLAB
  • Explore MATLAB's ODE solvers for numerical solutions
  • Study conditional statements and their applications in MATLAB
USEFUL FOR

Beginner MATLAB users, students studying differential equations, and anyone looking to implement step functions in MATLAB for mathematical modeling.

btbam91
Messages
91
Reaction score
0
Hey guys, I am extremely inexperienced with MATLAB and I"m struggling putting this ode into matlab.

y' = -a*y+u(t-1)-u(t-3)

I know that for y=u(t-1), you type:

if t<1
y=0;
else
y=1;
end

and for y=u(t-3):
if t<3
y=0;
else
y=1;

But I'm confused as to how you'd combine all of the above into a correction function m file!

Thanks!
 
Physics news on Phys.org
I am trying to understand your question here. Is your question you'd like to have a .m file that mimics the step function? type "help heaviside" see if that helps
 
Doesn't elseif solve the problem you are having?

if condition1
then something
elseif condition2
then something else
...
...
...
else
something
end
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
23
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K