From: ImageAnalyst on 25 Mar 2010 22:22 So it looks like (2) might be it. You've generated poly_plat in a different subroutine (which in turn calls polyfit). So poly_plat is a variable that is local to that subroutine. Unless you pass it back out, or make it global, it won't be in scope in the place where you want to use it. One easy thing to do is to put global poly_plat; in both functions (and in any other functions that will need to see poly_plat) and see if that helps.
From: Alex Larcombe on 25 Mar 2010 22:39 Thanks again ImageAnalyst, that fixed that particular problem, however, the exported file does not contain the data I intended it to. poly_plat is contains plateau fit coefficients (a slope and an intercept for each Breath) such that I wish the outputted text file to have three columns labelled "BreathNo", "Slope" and "Intercept" respectively and each of these columns to be filled with numbers. As it stands now: outfile_plateau = sprintf('%s-plateau.txt',rawtext); f_plateau = fopen(outfile_plateau,'wt'); fprintf(f_plateau,'BreathNo\tSlope\tIntercept\n'); fprintf(f_plateau,'%d\t%f\t%f\n',[k_breath; poly_plat]); fclose(f_plateau); the output file simply fills up like this: BreathNo Slope Intercept 1 2.000000 3.000000 4 5.000000 6.000000 7 8.000000 9.000000 10 11.000000 12.000000 13 14.000000 15.000000 16 17.000000 18.000000 19 20.000000 21.000000 22 23.000000 24.000000 25 26.000000 27.000000 28 29.000000 30.000000 There are 30 breaths in the file I am analysing, so that bit is correct, but I do not know why the rest of the file doesn't iterate properly...? ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <ac318462-1a03-43d0-8154-b31a5259c9c2(a)x12g2000yqx.googlegroups.com>... > So it looks like (2) might be it. You've generated poly_plat in a > different subroutine (which in turn calls polyfit). So poly_plat is a > variable that is local to that subroutine. Unless you pass it back > out, or make it global, it won't be in scope in the place where you > want to use it. > > One easy thing to do is to put > global poly_plat; > in both functions (and in any other functions that will need to see > poly_plat) and see if that helps.
First
|
Prev
|
Pages: 1 2 Prev: Interfacing Matlab with a Microprocessor Next: HELP: Newsgroup Email is required |