Borrar filtros
Borrar filtros

Print filenames, fit parameters, confidence intervals from fit function into a single table and output to a csv file?

1 visualización (últimos 30 días)
My code performs several fits on the same select data. The fits have different numbers of parameters. Two of these fits are shown below.
for k = 1:length(theFiles) %theFiles = text files from which the data is imported
names(k) = theFiles(k).name
[yfitRayl{k}, gof_rayl(k), a_rayl(k), ci(k)] = raylFit(dose{k}, sf{k});
[yfitLoglog{k}, gof_loglog(k), a_loglog(k), b_loglog(k), ci(k)] = raylFit(dose{k}, sf{k});
end
%===============================
% RAYLEIGH DISTRIBUTION FIT
%===============================
function [yfitRayl, gof, a] = raylFit(x, y)
[xData, yData] = prepareCurveData( x, y );
% Set up fittype and options.
ft = fittype( 'exp(-(x.^2)/(2*a.^2))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = 0.853031117721894;
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
coeffs = coeffvalues(fitresult);
a = coeffs(1);
ci = confint(fitresult);
yfitRayl = exp(-(x.^2)/(2*a.^2));
end
%==================================
% LOGLOGISTIC DISTRIBUTION FIT
%==================================
function [yfitLoglog, gof, a, b] = loglogFit(x, y)
[xData, yData] = prepareCurveData( x, y );
% Set up fittype and options.
ft = fittype( '1-cdf(''LogLogistic'',x,a,b)', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares','Lower',[-100 -100] );
opts.Display = 'Off';
opts.StartPoint = [0.241691285913833 0.403912145588115];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
coeffs = coeffvalues(fitresult);
a = coeffs(1);
b = coeffs(2);
ci = confint(fitresult);
yfitLoglog = 1-cdf('LogLogistic',x,a,b);
end
I want the table to take the following form..
k | Filename | Distribution Name | a | b | Upper CI (a) | Lower CI (a) | Upper CI (b) | Lower CI (b) | RMSE
-----------------------------------------------------------------------------------------------------------------------------------------------
1 | | Rayleigh | | | | | | | gof_rayl(1).rmse
Is it possible to print all this information from all of the fits into a single table so I can export it as a csv file? The best I can do so far is something like
table([a{k}; b{k}],'RowNames',{names(k);})
but this prints the data into multiple tables.

Respuestas (0)

Categorías

Más información sobre Fit Postprocessing en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by