week06-1 - Rutgers University School of Engineering Fall...

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

View Full Document Right Arrow Icon
Rutgers University School of Engineering Fall 2011 14:440:127 - Introduction to Computers for Engineers Sophocles J. Orfanidis ECE Department orfanidi@ece.rutgers.edu week 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
Week 1 - Basics – variables, arrays, matrices, plotting (ch. 2 & 3) Week 2 - Basics – operators, functions, program flow (ch. 2 & 3) Week 3 - Matrices (ch. 4) Week 4 - Plotting – 2D and 3D plots (ch. 5) Week 5 - User-defined functions (ch. 6) Week 6 - Input-output processing (ch. 7) Week 7 - Program flow control & relational operators (ch. 8) Week 8 - Matrix algebra – solving linear equations (ch. 9) Week 9 - Structures & cell arrays (ch. 10) Week 10 - Symbolic math (ch. 11) Week 11 - Numerical methods – data fitting (ch. 12) Week 12 – Selected topics Weekly Topics Textbook: H. Moore, MATLAB for Engineers , 2 nd ed., Prentice Hall, 2009
Background image of page 2
Input – Output Processing input and output functions, saving and loading files and variables, formatted screen output, file input and output opening, reading, writing, and saving files fopen, fclose, frewind fprintf, fscanf, fgetl, textscan reading and writing excel files reading, writing, playing audio files image files input, disp save, load fprintf, sprintf
Background image of page 3

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

View Full DocumentRight Arrow Icon
MATLAB has a large number of file processing functions for a variety of tasks: 1. file opening, loading, saving 2. text file processing 3. low-level file I/O 4. reading, writing spreadsheets 5. audio and video file processing 6. image & standard graphics files 7. specialized scientific data formats 8. file compression and internet file access 9. XML files
Background image of page 4
Useful I/O Functions: input, disp, num2str load, save fprintf, sprintf fopen, fclose, frewind, fread, fwrite fscanf, textscan, fgetl, importdata xlsread, xlswrite sound, wavread, wavwrite, wavplay, wavfinfo, wavrecord, audioplayer, audiorecorder, auidodevinfo imread, imwrite, image, imfinfo, im2java zip, unzip, tar, untar, gzip, gunzip >> help iofun >> doc iofun
Background image of page 5

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

View Full DocumentRight Arrow Icon
>> x = 10; disp('the value of x is:'); disp(x); the value of x is: 10 >> x = input('enter x: ') % numerical input enter x: 100 % 100 entered by user x = 100 >> y = input('enter string: ', 's'); % string input enter string: abcd efg >> y = input('enter string: ') enter string: 'abcd efg' y = abcd efg input/output functions: disp , input prompt string in single quotes string entered with no quotes string entered in quotes >> doc disp >> doc input
Background image of page 6
prompt = 'enter a 2x2 matrix A = '; A = input(prompt) enter a 2x2 matrix A = [1 2; 3 4] A = 1 2 3 4 N=3; M=2; prompt = ['enter a', . .. num2str(N),'x',num2str(M),' matrix A = ']; A = input(prompt) enter a 3x2 matrix A = [1 2; 3 4; 5 6] A = 1 2 3 4 5 6 brackets are required >> doc num2str >> doc int2str using num2str
Background image of page 7

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

View Full DocumentRight Arrow Icon
saving & loading variables: save, load >> doc save >> doc load Y = [1 2 3 4; 5 6 7 8]; save('test.dat', 'Y', '-ascii'); % text file save test.dat Y –ascii; % equivalent save test.dat Y; % binary file test.dat save Y; % creates binary file Y.mat >> type test.dat 1.0000000e+000 2.0000000e+000 3.0000000e+000 4.0000000e+000 5.0000000e+000 6.0000000e+000 7.0000000e+000 8.0000000e+000
Background image of page 8
X = load('test.dat') % read contents into X X = 1 2 3 4 5 6 7 8 load test.dat % creates new variable 'test' test = 1 2 3 4 5 6 7 8 saving & loading variables: save, load the file being loaded must be in the current working directory, or in MATLAB’s path (set/add path from File > Set Path in MATLAB desktop)
Background image of page 9

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

View Full DocumentRight Arrow Icon
fprintf('format_specs', variables);
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2011 for the course COMPUTER S 101 taught by Professor Orfandi during the Spring '11 term at Rutgers.

Page1 / 44

week06-1 - Rutgers University School of Engineering Fall...

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

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