MATLAB中图形生成顺序与数据处理

MATLAB中图形生成顺序与数据处理,matlab,matlab-figure,Matlab,Matlab Figure,我用可变步长处理大量数据(>>100k行) 我想创建一个图形,并在计算时绘制处理后的数据(用于在出现问题时终止运行脚本,或者用奇特的进度“动画”给“客户”留下深刻印象) 假设我们有“sourcefile.txt”,第n行有一列正数X(n),并且: 有很多线的X(n+1)X(n);其中N从小N的数千到大N的数十 我想到了: fID=fopen('sourcefile.txt'); figure;axes; % create figure act='0';threshold=0;N=0;DATA

我用可变步长处理大量数据(>>100k行)

我想创建一个图形,并在计算时绘制处理后的数据(用于在出现问题时终止运行脚本,或者用奇特的进度“动画”给“客户”留下深刻印象)

假设我们有“sourcefile.txt”,第n行有一列正数X(n),并且:

  • 有很多线的X(n+1)
  • X(n+n)>X(n);其中N从小N的数千到大N的数十
我想到了:

fID=fopen('sourcefile.txt');
figure;axes; % create figure
act='0';threshold=0;N=0;DATA=0;ii=0;
while ischar(act) % loop until end of file.
  ii=ii+1;N=0;
  while temp<threshold&&ischar(act) % loop until threshold is overflown (next step) or end-of-file is reached. 
    act=fgetl(fID);
    temp=temp+str2double(act);
    N=N+1;
  end
  line('xdata',ii,'ydata',temp/N,'Marker','o') % New point should appear
threshold=threshold+0.5; % Continue with new stopping rule.
end
fID=fopen('sourcefile.txt');
图形轴;%塑造形象
act='0';阈值=0;N=0;数据=0;ii=0;
而ischar(act)%loop直到文件结束。
ii=ii+1;N=0;
当温度时,请在使用
line
绘制线后尝试插入。这将刷新图形缓冲区并立即更新您的图形。如果不执行此操作,图形将显示为空白,直到循环完成,然后图形将与添加到图形中的对象一起显示

具体来说,我所说的是:

fID=fopen('sourcefile.txt');
figure;axes; % create figure
act='0';threshold=0;N=0;DATA=0;ii=0;
while ischar(act) % loop until end of file.
  ii=ii+1;N=0;
  while temp<threshold&&ischar(act) % loop until threshold is overflown (next step) or end-of-file is reached. 
    act=fgetl(fID);
    temp=temp+str2double(act);
    N=N+1;
  end
  line('xdata',ii,'ydata',temp/N,'Marker','o') % New point should appear

  %%%%%%%%%%%%// Change here
   drawnow;

threshold=threshold+0.5; % Continue with new stopping rule.
end
fID=fopen('sourcefile.txt');
图形轴;%塑造形象
act='0';阈值=0;N=0;数据=0;ii=0;
而ischar(act)%loop直到文件结束。
ii=ii+1;N=0;

而tempWow。。。简单而完美的解决方案。@Crowley-这是多年经验的结晶:)我只是让它看起来简单而已。很高兴它成功了!我不得不等一会儿。你太快了:-)@Crowley-哦,呵呵:)对不起:)我有快速回答问题的倾向。谢谢你的接受!作者们没想到,按9个键编辑代码就能解决问题,而答案和测试可能需要不到一分钟的时间:-)