[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cell array content
From: |
Pascal A. Dupuis |
Subject: |
cell array content |
Date: |
Fri, 5 Mar 2004 14:16:20 +0100 |
User-agent: |
Mutt/1.5.5.1+cvs20040105i |
Hello,
I've an application where I have to generate a csv file in order to
save a lot of things.
To generate it, I use code similar to:
fields={'Frequency', '%d';
'Span', '%f'};
where the first column is the field name and the second the
format. Then I concatenate the second colum in something like
format = "%d, %f\n"
After the computation, I generate a line as:
fprintf(OUT, format, var1, var2, ...)
The problem is to change the coding, with the time I had to add some
more variables, ...
A possible way to cope with this would be to allow a cell to contain code:
fields={'Frequency', '%d', 'freq';
'Span', '%f', 'span';
'Std Err', '%f', 'sqrt(sig2(1,1))' };
This way generating an output line would simply require evaluating the third
column elements.
So, a question about performances: as the content in the third column
is constant, are things like:
for indk = 1.. 100,
%# do some computation
for indi=1:rows(fields)
fprintf(OUT, fields(indi,2), eval(fields(indi, 3)));
endfor
endfor
optimised, i.e. compiled only once, or should I construct something like:
cmd="[
for indi=1:rows(fields)
cmd = [ cmd "," fields(indi, 3) ];
endfor
cmd = [cmd "]"];
for indk = 1.. 100,
%# do some computation
fprintf(OUT, format, eval(cmd))
endfor
Or is it simply possible to somehow arrange a cell element
to contain code which would be compiled only once ?
TIA
Pascal
--
Dr. ir. Pascal Dupuis
K. U. Leuven, ESAT/ELECTA (formerly ELEN): http://www.esat.kuleuven.ac.be/
Kasteelpark Arenberg, 10; B-3001 Leuven-Heverlee, Belgium
Tel. +32-16-32 10 21 -- Fax +32-16-32 19 85
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- cell array content,
Pascal A. Dupuis <=