Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Save and run beam4.m again. You should still get the same results. We can now move on to the next part of the tutorial.

...

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 line of code:

...

In the above line of code, 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, type help dlmwrite into the command window.

Output Important Values

...

Using fprintf

Another function that can be used to save important values is fprint fThe next step is to print out data in the command window. 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".

...