14-440-127 Recitation 1 Presentation

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

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

Ke Xu MATLAB Prompt Tells that MATLAB is ready for your command

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

View Full Document
Ke Xu Command window Command History window Current directory window
Ke Xu Help Open files New file

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

View Full Document
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)
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

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

View Full Document
Ke Xu
Ke Xu

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

View Full Document
Ke Xu Conditional Statements If (x>0) sign=1 end General form

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

View Full Document
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
Ask a homework question - tutors are online