Re: automation of loading multiple data file and fitting in separate directories
- From: helper <spam@xxxxxxxxxx>
- Date: Sun, 2 Apr 2006 07:41:41 -0500
Jonie wrote:
Thanks for the response,
I just was able to write a script. but I still have problems and
am
wondering if you could help me.
Inside the first for loop,
I realized that, in order to get 'textread' to work, current
working
directory has to be the same as the directory under which all the
data
files exist. Since I have multiple directories and would like to
use
their names as titles of the graph. It seems like I have to 'cd'
every
time to read the files.
For example,
the variable 'pathName' returns:
C:\Documents and Settings\Owner\Desktop\data_ABM\experiment-25
And 'dirName(3).name' returns
cBP=0.001
under which all the data files (.txt files) exist.
First question,
I would like to cd to the directory (i.e change the current
workding
directory to below)
C:\Documents and
Settings\Owner\Desktop\data_ABM\experiment-25\cBP=0.001
to get the data files read.
I don't how to do this using 'dirName(3).name' and 'pathName'
I tried 'cd(pathName/dirName) and it didn't work.
And then I have to cd to other directory, say
C:\Documents and
Settings\Owner\Desktop\data_ABM\experiment-25\cBP=0.5
I would appreciate it if you would let me know how to do this.
Thank you.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
freq = 10; % sampling frequence
% exp directory under which all
% the data directories exist with the names of the parameter we
swept
pathName=uigetdir;
dataDirName=dir(pathName); % data directory. its name is the
'parameter
name=value'
for (n=1:length(dataDirName))
dataFile=dir(fullfile(pathName,dataDirName(n).name,'report*'));
figure
hold on
for (i=1:length(dataFile))
[t,prev,avgNbor]=textread(dataFile(i).name,'%f %f
%f','headerlines',29,'commentstyle','shell');
scatter(t(1:freq:end),prev(1:freq:end),1,'y');
aggPrev(:,i) = prev;
end
avgPrev=mean(aggPrev,2);
s=std(aggPrev,0,2);
pTime=t(1:freq:end);
pAvg=avgPrev(1:freq:end);
pStd=s(1:freq:end);
errorbar(pTime,pAvg,pStd);
hold off
xlabel('weeks');
ylabel('prev');
title(dataDirName);
end
Rather than using CD, use an absolute path as the filename:
filename= fullfile(pathName,dataFile(i).name);
textread(filename,...
.
- Follow-Ups:
- References:
- Prev by Date: Re: shell commands within matlab
- Next by Date: Re: extrude an image
- Previous by thread: Re: automation of loading multiple data file and f
- Next by thread: Re: automation of loading multiple data file and fitting in separate directories
- Index(es):
Relevant Pages
|
Loading