LEC02 - ELEC2103 - Lec 2 Programming with Matlab 1 Chs 3...

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

View Full Document Right Arrow Icon
ELEC2103 ELEC2103 - Lec Lec 2 Programming with Matlab 1 Chs 3 & 4 of text, some graphics (ch 5) M-Files Files These can be a script – a list of instructions just as you would type, or a function , more like computer code use the Matlab editor % for comments type name of file without the “.m” to run it
Background image of page 1

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

View Full DocumentRight Arrow Icon
Functions Functions Start with the word function Matlab does not have strong (any?) type checking passes variables by value The name of the file is the name of the function Functions Functions >> lec2func([1 2; 3 4]) ans = Columns 1 through 5 1 2 1 4 1 3 4 9 16 27 Column 6 8 64 Acts on arrays, even characters Uses name of file not function
Background image of page 2
Control flow Control flow Loops for variable=expr Statements end expr has a number of columns , each placed in variable one at a time Inefficient in Matlab, try to avoid loops Matlab is an interpreter, more efficient to use vectors Control flow Control flow while expr statements end if expr statements
Background image of page 3

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

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

Page1 / 7

LEC02 - ELEC2103 - Lec 2 Programming with Matlab 1 Chs 3...

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