InterfaceMatlabandExcel

InterfaceMatlabandExcel - not understand this notation so...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Dr. Dobbs’ Howto: Interface Matlab to Excel (so you can format pretty looking tables for your lab reports) Matlab is an ideal tool for making great looking plots, charts, and graphs easily. It is not well suited to making nicely formatted tables. Since you will need nicely formatted tables to make your lab reports look professional, here are some tips for sending information back and forth from matlab to Microsoft Excel. 1. Open Microsoft Excel (Start Æ All Programs Æ Microsoft Office Æ Microsoft Excel). 2. If you want to, you can enter your data directly in excel. In this example I have entered data that counts from 21 to 40 in cells r1c1:r20c1 (think of this notation as being row 1, column 1 to row 20, column 1). I have saved my file as “matlabtest.xls” 3. Notice the formatting of cell addresses about (r1c1:r20c1). Some people have excel setup to label the columns with letters A,B,C,… and rows with numbers 1,2,3,… If this is the case for you, the cells would be names A1:A20. Matlab does
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: not understand this notation so it will be less confusion if you change excel to use this notation. Go to Tools Options General and put a check mark in front of R1C1 reference style. 4. Open matlab. Lets import the column of data from excel into matlab: myexcel = ddeinit('excel','matlabtest.xls') x = ddereq( myexcel, 'r1c1:r20c1' ) 5. Great we just copied one column of data from excel into matlab. Lets process it in some silly way in this case well simply add one to each element y = x + 1 6. ok now lets write this new data back into the excel table ddepoke(myexcel, 'r1c2:r20c2', y) This example may look rather trivial afterall, we could have just used an excel formula to create the second column but this becomes very useful when the equation for the second column is complicated. For other methods of reading or writing from an excel file, use matlab help to look up the methods: xlsinfo, xlsread, xlswrite...
View Full Document

This note was uploaded on 04/29/2008 for the course PHYS 257 taught by Professor Dobbs during the Fall '07 term at McGill.

Page1 / 4

InterfaceMatlabandExcel - not understand this notation so...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online