From: Martin on
"us " <us(a)neurol.unizh.ch> wrote in message <i04v41$l8e$1(a)fred.mathworks.com>...
> "Martin "
> > It did not work.
> >
> > B=[
> > 9 5
> > 23 4
> > 66 7
> > 75 2
> > ];
> > A=zeros(10);
> > A(B(:,1)=B(:,2);
> > ??? A(B(:,1)=B(:,2);
> > |
> > Error: The expression to the left of the equals sign is not a valid target for an assignment.
> >
>
> well... of course...
> you made a typo
>
> A(B(:,1)
> % must read
> A(B(:,1))
> % as shown in the original solution...
>
> us

I was wondering how I could automate this task. I have 1000 files like file B (tot_000.dat, tot_001.dat, and so forth). What would be a simple way to load each file, do the matrix creation, and output it to a new file? Thank You!
From: us on
"Martin "
> I was wondering how I could automate this task. I have 1000 files like file B (tot_000.dat, tot_001.dat, and so forth). What would be a simple way to load each file, do the matrix creation, and output it to a new file? Thank You!

a hint:

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F

us
From: Martin on
I did

for k=1:9
load(sprintf('/data/tot_00%d.dat',k));
end

which worked. Once I increase the number of files k above 9, I have problems. The file names are tot_001 through tot_999. How do I format the tot_%d so I can read 001 through 999?

Thank You.



"us " <us(a)neurol.unizh.ch> wrote in message <i05c5k$c67$1(a)fred.mathworks.com>...
> "Martin "
> > I was wondering how I could automate this task. I have 1000 files like file B (tot_000.dat, tot_001.dat, and so forth). What would be a simple way to load each file, do the matrix creation, and output it to a new file? Thank You!
>
> a hint:
>
> http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F
>
> us
From: us on
"Martin " <nikolom(a)gmail.com> wrote in message <i05smu$8f8$1(a)fred.mathworks.com>...
> I did
>
> for k=1:9
> load(sprintf('/data/tot_00%d.dat',k));
> end
>
> which worked. Once I increase the number of files k above 9, I have problems. The file names are tot_001 through tot_999. How do I format the tot_%d so I can read 001 through 999?
>
> Thank You.

one of the solutions

for i=0:50:150
fnam=sprintf('file_%3.3d',i);
disp(fnam);
end
%{
file_000
file_050
file_100
file_150
%}
% for more on formatting, see
help fprintf;

us
From: Martin on
I think I have figured out how to read all 999 files. I can process them in a do loop. The final step is to figure out how to automate generating 999 files containing the output. My input file names are tot_001 through tot_999. After I generate the output (a square matrix), how do I assign each output to file names Y_001 through Y_999?

Thank You!

"Martin " <nikolom(a)gmail.com> wrote in message <i05smu$8f8$1(a)fred.mathworks.com>...
> I did
>
> for k=1:9
> load(sprintf('/data/tot_00%d.dat',k));
> end
>
> which worked. Once I increase the number of files k above 9, I have problems. The file names are tot_001 through tot_999. How do I format the tot_%d so I can read 001 through 999?
>
> Thank You.
>
>
>
> "us " <us(a)neurol.unizh.ch> wrote in message <i05c5k$c67$1(a)fred.mathworks.com>...
> > "Martin "
> > > I was wondering how I could automate this task. I have 1000 files like file B (tot_000.dat, tot_001.dat, and so forth). What would be a simple way to load each file, do the matrix creation, and output it to a new file? Thank You!
> >
> > a hint:
> >
> > http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F
> >
> > us
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: china
Next: automatic gain control