14-440-127 Recitation 1 Presentation

14-440-127 Recitation 1 Presentation - : If condition...

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

View Full Document Right Arrow Icon
Ke Xu MATLAB Prompt Tells that MATLAB is ready for your command
Background image of page 1

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

View Full DocumentRight Arrow Icon
Ke Xu Command window Command History window Current directory window
Background image of page 2
Ke Xu Help Open files New file
Background image of page 3

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

View Full DocumentRight Arrow Icon
Ke Xu Set your working path • Save all your files on the J: Drive • add the J Drive to Matlab's path (File-> Set Path)
Background image of page 4
Ke Xu How to write an m-file and set variables • Type your commands and save as .m file • Pick a good filename • File name case sensitive • No need to declare variable before use • Data Types
Background image of page 5

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

View Full DocumentRight Arrow Icon
Ke Xu
Background image of page 6
Ke Xu
Background image of page 7

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

View Full DocumentRight Arrow Icon
Ke Xu Conditional Statements If (x>0) sign=1 end General form
Background image of page 8
Background image of page 9

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

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

Unformatted text preview: : If condition statements end Another example: if( x>5 | x<-5) disp('the absolute value is more than 5'); end; Ke Xu Example 1 Use MATLAB to calculate the expression where a =3, b =5 and c = -3. The code for this purpose is: Ke Xu Example 2 Find the odd or even number. Code: x = input('input a number = '); if mod(x,2) % same as “if ( mod(x,2) == 1 )” disp('odd'); end; if ~mod(x,2) % same as “if ( mod(x,2) ~= 1 )” disp(‘even'); end; For “mod”, type “help mod” in matlab ....
View Full Document

This note was uploaded on 02/29/2012 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 10

14-440-127 Recitation 1 Presentation - : If condition...

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

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