Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Matlab. Useful links

Similar presentations


Presentation on theme: "Introduction to Matlab. Useful links"— Presentation transcript:

1 Introduction to Matlab

2 Useful links http://mirlab.org/jang/books/matlabProgramming4beginner/slide/ http://www.mathworks.com/

3 Basic Settings Create new file : New Script Create new function : New -> Function

4 Basic Operation Don’t need to do variable declaration, but the first word of the variable must be English. Comments and multiple lines comments : Help : search for command usage ex : help mean

5 Basic Matrix Operation

6

7 Basic Function y = mean(x)calculate the mean of x y = abs(x)calculate the absolute value of x y = exp(x)calculate e^x y = sin(x)sine value of x y = cos(x)cosine value of x y = min(x)minimum value of x y = max(x)maximum value of x y = sum(x)summation of x

8 Useful wave generation function clear all; t=0:0.01:4; y1=square(2*pi*t); y2=square(2*pi*t,30); subplot(2,1,1),plot(t,y1); axis([-inf, inf, -1.2, 1.2]); subplot(2,1,2),plot(t,y2); axis([-inf, inf, -1.2, 1.2]);

9 For, While, If else

10 User-defined Function save a function as a.m file, and call the function from the main.m function [output variable] = name_of_function(input variable) ex : function [x, y] = two_vectors(r1,r2,t1,t2) d2r = pi/180; th1 = t1*d2r; th2 = t2*d2r; x = r1.*cos(th1)+r2.*cos(th2); y = r1.*sin(th1)+r2.* sin(th2); % main.m clear all; rr1 = 3; rr2 = 4; tt1 = 20; tt2 = 50; [xx, yy ] = two_vectors (rr1,rr2,tt1,tt2);

11 Plot

12

13 FFT

14 IFFT

15 Audio signal read and write Read : [x, fs] = wavread('C:\WINDOWS\Media\test_music.wav'); x : signal vector fs : sampling frequency Write: wavwrite(x,fs,wavfile);

16 Audio signal transmit and receive Transmit: 1.sound(x,fs); 2.wavplay(x,fs); Receive : 1. x = audiorecorder(fs,16,1); recordblocking(x,sec);% records ‘sec’ seconds x_array = getaudiodata(x); 2. x = wavrecord(array_length,fs)%how many data

17 Easy quiz


Download ppt "Introduction to Matlab. Useful links"

Similar presentations


Ads by Google