Wednesday, September 16, 2015

MATLAB File Read and Plot Example

Plot FFT using Matlab

fileID1 = fopen('real_part.txt','r');
rr = fscanf(fileID1,'%d');
fileID2 = fopen('im_part.txt','r');
ii = fscanf(fileID2,'%d');
rr_2 = rr.^2;
ii_2 = ii.^2;
sum = rr_2 + ii_2 ;
mag = db(sum);
plot(mag(1:32768));
grid on;

-------------------
Assume that there are 2 .txt file in the working directory. We can read and fill the values inside them to 2 array named as rr and ii.

No comments:

Post a Comment