【发布时间】:2017-07-05 20:43:34
【问题描述】:
我有几个文件打算在 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
【问题讨论】:
-
如果您的绘图在处理过程中未显示,您可能需要在绘图函数后添加
pause(0.001),以便您的计算机有时间渲染图形。 -
尝试添加暂停(0.001)它需要时间来处理。还想知道如果我只添加没有 for 循环的暂停是否会起作用,就像下面的代码
code %Find time N = size(prcdata(:,1),1); t=T*(0:N-1)'; x=0:(T*(0:u-1)'); plot(x,prcdata(:,4)); drawnow; end -
我曾经使用过这个解决方案。可能会有所帮助maybe this post can help you
-
谢谢Belgarath 我会看看那个帖子 我已经使用了该代码并保持运行需要一段时间,因为这些数据很大。