matlab Flashcards
to know the size of a matrix
size(the name of the variable)
to call out a certain number in the matrix
variable name(row number,column number)
x(3,1)
to call out an entire row in a matrix
using :
x(3,:) is calling out row 3 , nafs l klam m3a l column
dot multiplication between two matrix bytala3 scalar
dot(x,y)
cross product between two vectors
cross(x,y)
the constant e
exp(1)
zero or ONE matrix with diff rows and columns
zeros(rows,columns)
ones(rows,columns)
determinant of a matrix
det(A)
to display a value or a variable
disp(A)
disp(‘ i found it ‘ )
for loop
for i=1:10
ekteb ele anta 3awzo
end
to plot
to enter a title
to label x and y axis
sub plot
plot(x,y)
title(‘A plot of sin x ‘) 3la sbeel el msaal
xlabel(‘time’) ylabel(‘3afreet’)
subplot(2,1,1)
plot m4 3aref eh
subplot(2,1,2)plot 7aga tanya
3adad el steps mabeen value and another value
x=linspace(0,100,200)
hy3ed mn 0 l 100 f 200 step
to plot 2 graphs 2 xs and 2 ys on the same graph
plot(x,y,x,y_2)
plot(x,y,’–‘,x,y_2,’.’)
hyrsem l graph l 2awalany f dashes wel tany f no2at
bar chart
bar(x)
bar(x,y) hyrsemlak bars :D
pie chart
pie(x)
scatter chart used lama l data m4 ordered kwyes
scatter(x,y)
3d plotting of a matrix
surf(z)
contour(z)
to read wave files ( any file that contains digital sound recorded for example by Audicity )to check the size of the matrix
d=wavread(‘ Filename.wav’); or u can use audioread(‘Filename.mp3 or wav ‘ )
size(d)
to let matlab say outloud the wave file u recorded
[d,fs]=wavread(‘Filename.wav’);sound(d,fs);
NB: d is the variable name, fs is frequency sampling
to reverse a sound signal and audiowrite it in a new mp3 file
d2=flipud(d);
d3=audiowrite(‘helloworldreversed.mp4’, d2, fs);
[d3,fs]= audioread(‘helloworldreversed.mp4’);
sound(d3,fs)
to speed up the sound
d4=downsample(d,2);
is like doubling the frequency of a wave..
to draw the FFT “ fast fourier transform “ which is aka frequency spectrum .. u can also draw only the real part of the signal ( while ignoring the imaginary part )
y=fft(d);
z=real(y);
plot(z)
spectogram shows different frequencies with change of time. u need to have a tool box from MATLAB company to use it.
spectogram(y2)
applying a low pass filter an audio stream
dlp is the low passed audio
b=ones(40,1)/4;
[d.fs]=audioread(‘Helloworld.mp3’);
dlp=filter(b, 1, d);
sound(‘dlp’)