On Mon, 06 Jun 2011 19:18:25 +0200, gpipc <gp...@cup.uni-muenchen.de> wrote: > On Mon, 6 Jun 2011 09:53:16 -0700 (PDT), hodjat hajian > <hh.solidst...@yahoo.com> wrote: >> Dear users hi, >> I extract some data in a comma-delimited format in a .dat file, as >> below: >> flux1:, 0.25, 2.64484059275628e-4 >> flux1:, 0.250400801603206, 2.87434928639728e-4 >> flux1:, 0.250801603206413, 3.12270609926369e-4 >> . >> . >> . > > Hi Hodjat, > these lines work in Matlab, you mighthave to modify them a bit to get them > working for Octave; you have to assign to the variable flux_data_file the > path of your file > > > > fid = fopen (flux_data_file, 'r'); > [val, count] = fscanf (fid, ' flux1:, %f , %f', Inf); > fclose(fid); > > > Curiously the space before the characters flux1:, in the conversion > specification string is important, otherwise the program reads only the > first line of the input file > > > Giovanni
I was forgetting the rest: then the variable val is a one-dimensional array, so to sort out frequency and transmission you have to do something like n_col = 2; Meep_f = zeros(length(val)/n_col, 1); % Meep frequency transmission = zeros(length(val)/n_col, 1); for m = 1:length(val)/n_col Meep_f(m) = val(n_col*m-n_col+1); transmission(m) = val(n_col*m - n_col+2); end (I adapted it from something I wrote for myself, and did not try it on your data, so that there could be a mistake or a mistype, but the idea is right) G. ---------------------------------------- Message sent by Cup Webmail (Roundcube) _______________________________________________ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss