Versions Compared

Key

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

Plot σx vs. r(Take 3: File Input/Output)

...

Read

...

in

...

[A

...

]

...

from

...

a

...

file

...

HTML
<iframe width

...

="600" height="338" src="//www.youtube.com/embed/

...

YbyfEIkgYHA?rel=0" frameborder="0" allowfullscreen></iframe>


Read in [B] from the same

...

file

Note that the following video contains a part where the text file is read into Excel. This is only for illustration purposes (to check the range that we need to feed into the dlmread function). The data is still read from the .txt file, so you can skip following the Excel steps and just watch these steps being done in the video.

...

HTML
<iframe width

...

="600" height="338" src="//www.youtube.com/embed/

...

hdbyuLxkTCg?rel=0" frameborder="0" allowfullscreen></iframe>


Output Values Using dlmwrite

Just as you can read in values from a text file to a matrix, you can also write a matrix to a text file. The function for this is called dlmwrite. Consider the following syntax:

...

We write matrix A to a text file named output_file, and we use a space as a delimiter. Add this line of code to beam4.m and run it. You should see a text file named output_file appear in your working directory. If you wish to learn more about dlmwrite, use your best friend...documentation!

Output Important Values Using fprintf

Another function that can be used to save important values is fprint f. Suppose we are asked to report the numerical values of the bending stress for inner radius =0.5, 1.0, and 1.5 cm. These values are already contained in the vectors "ri" and "sigma_x".

...