Saturday, December 15, 2012

Useful Matlab commands

These are some of the commands that I have used in Matlab pretty often. I just put them here for me to have a quick reference. Don't expect any fancy things... :)

t=(0:1/44e3:99999*1/44e3);
osc=sin(2*pi*t*3.9917e+003)';
mixer_out=filter_out.*osc;
bsdelayed=[zeros(25640-13170,1) ;bs];
bsshift=circshift(bs,22800);

figure
subplot(2,1,2)
plot(x,’r’)
clf
hold on
close all  % Closes all figures

filterbuilder
Y=Filter(Hbp,x);

z=amdemod(rx,3.9917e+003,44e3);
fmdemod;
pmdemod;
b=upsample(b,4400); % Insert zeros in between
bs=conv(b,symbol);
abs(fft(rx));

READ WAV FILE
[filename, pathname]=uigetfile('*.wav')
[m d]=wavfinfo(strcat(pathname,filename))
rx = wavread(strcat(pathname,filename));

READ BINARY FILE
[filename, pathname]=uigetfile('.\*.*')  % Open the dialog box
filen=strcat(pathname,filename) % Builds the full file path
fileID = fopen(filen)  % Opens the file and assigns it an ID
A = fread(fileID, inf, 'int16');   % Reads the full file into an Array A, assuming they are 16b integers
plot(A)

% See more http://www.mathworks.com/company/newsletters/articles/Matrix-Indexing-in-MATLAB/matrix.html
v = [16 5 9 4 2 11 7 14];
v(3) % gives 9
v([1 5 6]) % Gives 16, 2, 11
v(3:7) % Gives 9 4 2 11 7

http://www.mathworks.com/support/2014a/matlab/8.3/demos/working-with-arrays-matlab-video.html

No comments:

Post a Comment