Author: Rajesh Bhaskaran, Cornell University
Problem Specification
1. Euler Integration
2. Array Pre-Allocation
3. Plotting
4. Function Creation
5. Structure Creation
Exercises
Comments
Step 5: Structure Creation
We will create a "structure" to contain the m and k values. You can think of a "structure" as a box that can contain any type of MATLAB entity. We will then pass only the structure or box to the Euler function. In the function, we'll unpack the box to get the m and k values. The advantage of collecting values in a box is that it simplifies the function call. If we need to pass more values like, say, the initial conditions, into the function, we just need to add them to the box i.e. the structure. The function call will not change. Follow the steps in the video to create a structure containing the m and k values. We'll then use the debugger to step through the code and understand how this changes how variables are handled.