Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Include Page
SIMULATION: ANSYS Google Analytics
SIMULATION: ANSYS Google Analytics

The following video shows how to specify constants such as the spring mass m and spring constant k.

HTML
 <iframe width="600" height="338" src="//www.youtube.com/embed/uXURYBVEv-c?rel=0" frameborder="0" allowfullscreen></iframe> 


We next specify the initial conditions and run the code that we have so far as shown in the video below. While running the code, we use the debugger to step through statements to understand what they do.

HTML
 <iframe width="600" height="338" src="//www.youtube.com/embed/IyRJmOd48NE?rel=0" frameborder="0" allowfullscreen></iframe> </iframe>


The following video shows how to We have seen students write up huge chunks of code at one go that produces some obscure error. Students find that no amount of cursing and swearing at the computer fixes the error. To avoid this trap, we will build our code incrementally, testing at each stage. We first implement the Euler's integration method for one time-step as shown below and then will extend it to multiple time-steps.

HTML
 <iframe width="600" height="338" src="//www.youtube.com/embed/3khcp_ZjnaU?rel=0" frameborder="0" allowfullscreen></iframe> 


We move on to extend our code, or script in MATLAB lingo, to perform the Euler integration over multiple time-steps by looping over the appropriate statements as shown in the video below.

HTML
 <iframe width="600" height="338" src="//www.youtube.com/embed/OaGJsamM8rw?rel=0" frameborder="0" allowfullscreen></iframe> 

...

Our script saves only the final location of the mass. We are also interested in saving the intermediate locations so that we can make a plot of position vs. time. We do this by creating arrays for the position and time as shown in the video below.

HTML
<iframe width="600" height="338" src="//www.youtube.com/embed/8g4kSDT8SZo?rel=0" frameborder="0" allowfullscreen></iframe>



Go to Step 2: Pre-Allocation

Go to all MATLAB Learning Modules