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

...

Plot σx vs. ri

...

 (Take 2)

Vectorize σx Calculation

Again, we pick MATLAB's brain on vectorization:

...

MATLAB's vectorization example shows you how you can create the vector ri using the : operator. Let's check how we can use this animal. At the command prompt, type

...

How do your values of sigma_x correspond to the values from beam2.m? Mine are the same ... yipppee!

Plot σx vs. ri: Take 2

Recycle the plot section from our program in Step 3. Copy this section and append it to your current program:

...

Execute this statement by clicking on the step icon   in the Editor. This should bring up the Figure 1 window. Note that the green arrow moves to the next statement indicating that execution is paused there.
Click again on the step icon. clf will clear anything in the current figure i.e. figure 1. This means you start with a clean slate.

...

Keep an eye on the axes lines and labels in your figure as you step through the set(gca,...) command. Did you see that this command changed the font and line styles for the axes? gca stands for get current axes handle; once we have the handle, we can manipulate the axes properties (yup, same as my office). You can use this statement after any plot command; if you have multiple plot commands for the same figure, this statement needs to be used only once.

Now we will make the curve in the plot thicker. Keep an eye on the σx curve as you step through the set(h,...) statement. Did you notice a change in the line style?

Retain an eye on your figure as you step through the remaining statements. You should end up, as below, with a nice-looking plot with legible lines and text. The axis square statement makes the current axis box square in size.

...

figure(1); %Create figure #1
clf; %Clear current figure
h=plot(,,'');
set(gca,'Box','on','LineWidth',2,...
'FontName','Helvetica',...
'FontSize',14);
%Set axis properties
set(h,'LineWidth',2);
%Set linewidth for curve
xlabel('');
ylabel('');
title('');
axis square; %Make axis box square

Go to Step 5: Plot σx σx vs. ri, ri (Take 3: File Input/Output)

Go to all MATLAB Learning Modules