Thursday, 18 December 2008

Commonly Used Commands in MATLAB

1. sin(x) >> Computes sine value of x radian.
To plot a sine wave we use the following commands
syntax: t = 0:0.01:1
y = a*sin(w*t); %a = amplitude
plot(t,y)
note: y is a column matrix which contains all the value to plot sine wave

2. cos(x) >> Computes the cosine value of x radian. This is similar to sin(x).

3. plot >> plots a continuous wave.
e.g: plot(t,z) This plots a continuous wave, with t on x axis and z on y axis.
Note: It's important that both the matrix are of same size.

4. subplot >> The figure window is split according to our commands.
e.g: subplot(2,2,1) >> This will divide the figure window into a 2x2 matrix, and the 1st one is accessed now to draw.
Note: plot and stem functions should be used only after subplot function

5. stem >> It is the discrete domain counter part of plot.

6. xlabel('Text') >> This command is usually used after plot and stem function. This command will give a label named 'Text' to x axis of the plot.
e.g: plot(t,y);
xlabel('Time')
ylabel('Amplitude')
title('Sine Wave')

8. ylabel('Text') >> Similar to xlabel.

9. title('Text') >> Gives the title to a plot or subplot.

10. abs(x) >> The command computes the absolute value of x. If x is complex it returns the magnitude.

11. angle(x) >> this command computes the phase angle of x in rad.

12. ones(p,q) >> generates a p x q matrix of ones.

13. zeros(p,q) >> generates a p x q matrix of zeros.

14. mod(m,N) >> Computes m mod N.

15. rem(n,M) >> returns the reminder after dividing n by M.

16. log10(x) >> Computes the base 10 logarithm of elements of x.

17. axis([xmin xmax ymin ymax]) >> Sets scaling for x and y axes for the current plot.



querrymail@gmail.com

0 comments: