我有一些我打算在Matlab中绘制的文件。我已经加载了文件,我想实时绘制它。因为我想看到它正在被绘制。
%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
答案 0 :(得分:0)
对象通过累积来自流数据源的数据来优化线动画。使用animatedline函数创建初始动画线后,可以向线添加新点,而无需重新定义现有点。通过设置其属性来修改动画线的外观。
答案 1 :(得分:0)
我知道一种启发式方法,但它确实有效:
for u = 1:N;
x(u)=0:(T*(0:u-1)');
plot(x(1:u),prcdata(:,4));
pause(0.01);
end