0

I'm new to Matlab and I'm currently trying to save the fitting results (cfit) to a txt file. The txt should come with columns for each of the fitting parameters and separated by tabs.

I'm taking the results of the fitting as

[cf,gof] = fit(freq,data,ft_,fo_);
vals = [cf.a,cf.b,cf.c];

and I'm trying to save it to a txt file by using:

fprintf(fileID,'%s \t %7f \t %7f \t %7f \n',token,vals);

but I'm frequently getting the error: "Function is not defined for 'cell' inputs." How do I have to transform the fitting output in a way that it can be handled by fprintf and get everything saved to a txt file?

Thanks!

1 Answers1

0

Not sure about that exact error maybe token is not what the fucntion expects or some of the cf.a/b/c are not defined.

But saving to a file can be done as follows:

vals = [1,2,3];
fid = fopen('test.txt', 'w');
fprintf(fid,'%7f \t %7f \t %7f \n',vals);
fclose(fid);
mpaskov
  • 1,234
  • 2
  • 11
  • 21