02.03.2016 Views

MATLAB by rudra pratap

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

60 Tutorial Lessons<br />

EXERCISES<br />

1. Using the publisher from the editor window: Open the file spiralplot.m<br />

that you created while working with Lesson 11. You can open the file <strong>by</strong><br />

following File ---> Open from the menu or from the command window with<br />

either edit spiralplot .m or open spiralplot .m. Once the file is open in<br />

the editor, select Publish from the File menu (see Fig. 2.17) of the editor<br />

window, or click on the publish icon (next to the printer icon in the menu<br />

bar). The script open in the editor will be published to an HTML file and<br />

<strong>MATLAB</strong> will automatically open the HTML file for your perusal.<br />

5nPa_tfl_,<br />

flra.ft;t .. IKU-<br />

••gtSttu;>,..<br />

Prim ••.<br />

l?/,,: s:ti.Yi.<br />

1 [UUU/.J\IlJSf){fitlp1ot.m<br />

2 /l.lst1S/.-IMA.Tt.A!:Ibe.i#.un<br />

l i-U(fs$/.,4gr-A¢'1iaJW.o,Jn 22<br />

4 rtiuuj •. ..mfi!e5}dtdt.m ·<br />

2 3<br />

£xltMATI.AB XQ i 24<br />

25<br />

i 26<br />

27<br />

Cell e1.ecut1011 buttons<br />

Figure 2.17: The <strong>MATLAB</strong> publisher can be invoked from the File menu when the<br />

script is open in the editor window.<br />

2. What are those cells? A cell, in a script file, is a set of commands enclosed<br />

between two cell separators (lines that start with %%). You can execute a cell<br />

independent of other cells. You can also execute one cell and then the next<br />

<strong>by</strong> simply clicking on the cell execution option buttons (see Fig. 2.17) in the<br />

toolbar of the editor. Move your mouse on these buttons to see what each<br />

one does.<br />

Now, open the spiralplot.m file again (if you have closed it) in the editor<br />

and add the following two cells at the end of the file. You can just type %%<br />

to start a new cell or click on the Insert Cell Divider button in the toolbar to<br />

in:>crt it.<br />

%% Polar to Cartesian coordinates<br />

x = r.*cos (theta) ;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!