How can I loop this code for several data files and finally accumulate all the plots together?
Show older comments
I have a code:
B=load('Data1.dat');
Dat=[B(:,1) B(:,2)];
nbins=[1000 1000];
n=hist3(Dat,nbins);
n1 = n;
n1(size(n,1) + 1, size(n,2) + 1) = 0;
xb1 = linspace(min(Dat(:,1)),max(Dat(:,1)),size(n,1)+1);
yb1 = linspace(min(Dat(:,2)),max(Dat(:,2)),size(n,1)+1);
figure
pcolor(xb1,yb1,n1);
xaxis= 0:0.1:40;
set(gca, 'Xticklabel', {xaxis})
set(gca, 'Yticklabel', {xaxis})
xx1=sum(n1);
I want to reapeat this code for Data1.dat, Data2.dat, Data3.dat,.......Datan.dat and finally put the results in a single plot like:
plot(xb1, xx1,':b',xb2,xx2,':r',......xbn,xxn,':k')
where xb2,xb3...xbn and xx2,xx3....xxn are the values of xb1 and xx1 in the code for second third etc... nth run(corresponding to each Data fle).
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!