Versions Compared

Key

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

...

Wiki Markup
Read in \[B\] from a File

Wiki Markup
Hey, if _\[A\]_ can be read in from a file, why not read _\[B\]_ from the same file?

Wiki Markup
Append the elements of _\[B\]_ to _input_data.txt_ and save the file:

Image Removed

Now we need to tell MATLAB to:

  1. Read in the first two rows and assign it to A.
  2. Read in the last two rows and assign it to B.

An additional complication is that A and B have different number of columns. To handle this mess, we turn to the following nugget from the dlmread documentation:

Panel

Wiki Markup
M = dlmread('filename', delimiter, range) reads the range specified by range = \[R1 C1 R2 C2\] where (R1,C1) is the upper left corner of the data to be read and (R2,C2) is the lower right corner. You can also specify the range using spreadsheet notation, as in range = 'A1..B7'.

Key point: MATLAB starts counting the rows and colums at 0 rather than 1. So the first row is 0, second row is 1 and so on. The same thing applies to columns also. See below for an input with n rows and m columns. (i, j) are the row, column coordinates.

Wiki Markup
{{\[ (0,0) (0,1) (0,2)...(0,m-1) \]}}

Wiki Markup
{{\[ (1,0) \____________________\_ \]}}

Wiki Markup
{{\[ (2,0) \____________________\_ \]}}

Wiki Markup
{{\[  ...   \______________________\_ \]}}

Wiki Markup
{{\[(n-1,0) \__________\_ (n-1,m-1)\]}}

Wiki Markup
Once again, edit _beam4.m_. Now, use the <span style="color: #660099"><strong><em>dlmread</em></strong></span> command with the delimiter and range inputs to extract both <span style="color: #660099"><strong><em>A</em></strong></span> and <span style="color: #660099"><strong><em>B</em></strong></span> at the same time. The delimiter should be '', the range should be {{\[0 0 1 1\]}} for <span style="color: #660099"><strong><em>A</em></strong></span> and {{\[2 0 3 0\]}} for <span style="color: #660099"><strong><em>B</em></strong></span>. Remember to add your semi-colons.

...

Widget Connector
width600
urlhttps://www.youtube.com/watch?v=hdbyuLxkTCg
height370

Output Values Using dlmwrite

...