Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Include Page
MATLAB Google Analytics
MATLAB Google Analytics
Include Page
Intro Learning Module - Panel
Intro Learning Module - Panel
Panel

Problem Specification
Step 1: Find Reactions RA, RB
Step 2: Calculate σx for ri = 1 cm
Step 3: Plot σx vs. ri
Step 4: Plot σx vs. ri: Take 2
Step 5: Plot σx vs. ri, Take 3: File Input/Output
Step 6: Plot σx vs. ri, Take 4: Functions

...

Plot σx vs. ri

Calculate σx at O

Essentially, we need to repeat our previous calculation of σx at O for a range of rivalues. One way to do this is to loop over the previous calculation. There are two types of loops: for and while. Let's check the documentation to see what MATLAB provides for loops.

Home (tab) > Help > Documentation

There are two types of loops: for and while. Enter for loop in the search bar and then select for which is the first entry up top. Look at the first example. This shows the format of the for loop. You can often speed up the execution of MATLAB code by replacing for and while loops with vectorized code. That is what we'll do in Step 4. Let's stick it out with slowpoke for loop for now.

...

How do we know if the results are right? Let's spot-check the result for ri=1e-2 m against the previous step; this value of ri corresponds to k=6. What is your value of sigma_x(k) for k=6? You can check this from the output or by typing sigma_x(6) at the command line. My value is exactly the same as in Step 2 ... nailed that one! How about you?

Now that we have spot checked our result, add a semi-colon after the sigma_x statement to avoid cluttering up the output.

Plot σx vs. ri

Let's pick MATLAB's brain on how to make a plot.

Help > ( contents tab) > matlab > getting started > graphics > using basic plotting functions

Home (tab) > Documentation (icon) > Search: Plotting Functions > Plotting Functions

Note that you can access this exact page without using the search field. Doing this will give you a sense of how to navigate the documentation. 

Home (tab) > Documentation (icon) > MATLAB > Graphics > 2-D and 3-D Plots > Plotting Basics > Plotting Functions

This page contains These help pages contain a lucid description of the extensive plotting capabilities available in MATLAB. When looking for plotting help, this would be the first place to turn to.

...

Click the Run icon in the Editor. The underscore symbol (_) gives subscripts and \sigma gives the corresponding Greek symbol. See

Help > Index (tab) > Greek letters and mathematical symbols

 

See my entire program here (right click and select save target as, or just left-click and copy-paste in the editor).

...

Recall that "you can often speed up the execution of MATLAB code by replacing for and while loops with vectorized code". We are into speed, so let's vectorize our program.

Go to Step 4: Plot σx vs. ri:  (Take 2See and rate the complete Learning Module)

Go to all MATLAB Learning Modules