I have a few files which I am planning to plot in Matlab. I have loaded the files and I wanted to plot it in real time. As in I want to see it as it is being plotted.
%clear
[filename, pathname] = uigetfile('*.raw;*.prc', 'Pick raw or processed data file');
N=str2double(filename(5:6));
Fs = 145.3*10^3;
T = 1/Fs; % Sampling period
if isequal(filename(end-2:end),'raw')
% load raw data file
fid = fopen([pathname filename],'r','l');
A=fread(fid,inf,'*uint16')'; %s=ftell(fid);
B=bitand(A, hex2dec('0FFF')); C=bitshift(A,-12);
channels=sort(C(1:N));
rawdata(int16(numel(A)/N)+2,N)=uint16(0); % Need to add +2 due to data loss
for ii=1:N
%rawdata(:,ii)=B(C==channels(ii)); can't use due to data loss
temp=B(C==channels(ii));
rawdata(1:numel(temp),ii)=temp;
end
plot(3.3/4095*single(rawdata))
legend(int2str(channels'))
else
%load processed file
fid = fopen([pathname filename],'r','b');
A= fread(fid,inf,'*single')';
prcdata=reshape(A,N,[])';
%Find time
N = size(prcdata(:,1),1);
t=T*(0:N-1)';
for u = 1:N;
x=0:(T*(0:u-1)');
plot(x,prcdata(:,4));
drawnow;
end
end