Domanda

I have a large number (~1000) of files from a data logger that I am trying to process.

If I wanted to plot the trend from a single one of these log files I could do it using

plot(timevalues,datavalues)

I would like to be able to view all of these lines at same time in a similar way to how an oscilloscope has a "persistant" mode.

Oscilloscope Diplay

I can probably cobble together something that uses histograms but am hoping there is pre-existing or more elegant solution to this problem.

È stato utile?

Soluzione

You can do exactly what you are suggesting yourself, i.e. plotting the heatmap of the signals.

Consider the following: I'll build a test signals (out of sine waves of different amplitude), then I'll plot the heatmap via hist3 and imagesc.

The idea is to build an auxiliary signal which is just the juxtaposition of all your time histories (both in x and y), then extract basic bivariate statistics out of that.

 % # Test signals
 xx = 0 : .01 : 2* pi;
 center = 1;
 eps_ = .2;
 amps = linspace(center - eps_ , center + eps_ , 100 );

 % # the auxiliary signal will be stored in the following variables
 yy = [];
 xx_f = [];

 for A = amps
   xx_f = [xx_f,xx];
   yy = [yy A*sin(xx)];
 end 

 % # final heat map
 colormap(hot)
 [N,C] = hist3([xx_f' yy'],[100 100]);
 imagesc(C{1},C{2},N')

enter image description here

You can use also jet colormap instead of hot colormap for readability. In the following the amplitude is gaussian instead of homogeneus.

enter image description here

Altri suggerimenti

here's a "primitive" solution that is just using hist:

%# generate some fake data

x=-8:0.01:8;
y=10*sinc(x);
yy=bsxfun(@plus,y,0.1*randn(numel(x),1000)' );
yy(randi(1000,1,200),:)= 5-randi(10)+ circshift(yy(randi(1000,1,200),:),[1 randi(numel(x),1,200)]); 

%# get plot limit parameters

plot(x,yy)
yl=get(gca,'Ylim');
xl=get(gca,'Xlim');
close all;


%# set 2-d histogram ranges

ybins=100;
xbins=numel(x);
yrange=linspace(yl(1),yl(2),ybins);
xrange=linspace(xl(1),xl(2),xbins);

%# prealocate

m=zeros(numel(yrange),numel(xrange));

% build 2d hist
for n=1:numel(x)
    ind=hist(yy(:,n),yrange);
    m(:,n)=m(:,n)+ind(:);
end

imagesc(xrange,yrange,m)
set(gca,'Ydir','normal')

enter image description here

Why don't you normalize the data and then add all the lines together? You could then plot the heatmap from the single datafile.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top