How to fit power-law to each column of data arranged in a table?
Hello all! Here my question:
I have a table displaying 1000 columns (spikes_mtx). Each column has 400 rows of data displaying exponential decay over 100s time (std_time).
I’d like to fit a three-coefficient power-fit model (y = a*x^b+c) to each column so as to obtain:
A table with x1000 a coefficient (coming from the 1000 exponential decays)
A table with x1000 b coefficient (coming from the 1000 exponential decays)
A table with x1000 c coefficient (coming from the 1000 exponential decays)
A table with x1000 fit goodness parameters (coming from the 1000 exponential decays)
All tables stored in one single structure (results.STD). My code doesn’t function, any recommendation? Thanks in advance!
ft = fittype( ‘power2’ ); % Power Fit: y = a*x^b+c
opts = fitoptions(ft); % Power fit options
opts.StartPoint = [1 -1 0];
opts.Lower = [0 -Inf -Inf];
opts.Upper = [Inf 0 Inf];
for i=1:length (spikes_mtx)
[xData, yData] = prepareCurveData(std_time,spikes_mtx(:,i)); % x = std_time y = spikes_mtx
[fitresult, gof] = fit( xData, yData, ft, opts ); % Goodnes of the Fit R^2
results.STD.Coeff.a(1,i)=S.std.fitmodel.a;
results.STD.Coeff.b(1,i)=S.std.fitmodel.b;
results.STD.Coeff.c(1,i)=S.std.fitmodel.c;
results.STD.gof.sse(1,i)=S.std.gof.sse;
results.STD.gof.rsquare(1,i)=S.std.gof.rsquare;
results.STD.gof.dfe(1,i)=S.std.gof.dfe;
results.STD.gof.adjrsquare(1,i)=S.std.gof.adjrsquare;
results.STD.gof.rmse(1,i)=S.std.gof.rmse;
endHello all! Here my question:
I have a table displaying 1000 columns (spikes_mtx). Each column has 400 rows of data displaying exponential decay over 100s time (std_time).
I’d like to fit a three-coefficient power-fit model (y = a*x^b+c) to each column so as to obtain:
A table with x1000 a coefficient (coming from the 1000 exponential decays)
A table with x1000 b coefficient (coming from the 1000 exponential decays)
A table with x1000 c coefficient (coming from the 1000 exponential decays)
A table with x1000 fit goodness parameters (coming from the 1000 exponential decays)
All tables stored in one single structure (results.STD). My code doesn’t function, any recommendation? Thanks in advance!
ft = fittype( ‘power2’ ); % Power Fit: y = a*x^b+c
opts = fitoptions(ft); % Power fit options
opts.StartPoint = [1 -1 0];
opts.Lower = [0 -Inf -Inf];
opts.Upper = [Inf 0 Inf];
for i=1:length (spikes_mtx)
[xData, yData] = prepareCurveData(std_time,spikes_mtx(:,i)); % x = std_time y = spikes_mtx
[fitresult, gof] = fit( xData, yData, ft, opts ); % Goodnes of the Fit R^2
results.STD.Coeff.a(1,i)=S.std.fitmodel.a;
results.STD.Coeff.b(1,i)=S.std.fitmodel.b;
results.STD.Coeff.c(1,i)=S.std.fitmodel.c;
results.STD.gof.sse(1,i)=S.std.gof.sse;
results.STD.gof.rsquare(1,i)=S.std.gof.rsquare;
results.STD.gof.dfe(1,i)=S.std.gof.dfe;
results.STD.gof.adjrsquare(1,i)=S.std.gof.adjrsquare;
results.STD.gof.rmse(1,i)=S.std.gof.rmse;
end Hello all! Here my question:
I have a table displaying 1000 columns (spikes_mtx). Each column has 400 rows of data displaying exponential decay over 100s time (std_time).
I’d like to fit a three-coefficient power-fit model (y = a*x^b+c) to each column so as to obtain:
A table with x1000 a coefficient (coming from the 1000 exponential decays)
A table with x1000 b coefficient (coming from the 1000 exponential decays)
A table with x1000 c coefficient (coming from the 1000 exponential decays)
A table with x1000 fit goodness parameters (coming from the 1000 exponential decays)
All tables stored in one single structure (results.STD). My code doesn’t function, any recommendation? Thanks in advance!
ft = fittype( ‘power2’ ); % Power Fit: y = a*x^b+c
opts = fitoptions(ft); % Power fit options
opts.StartPoint = [1 -1 0];
opts.Lower = [0 -Inf -Inf];
opts.Upper = [Inf 0 Inf];
for i=1:length (spikes_mtx)
[xData, yData] = prepareCurveData(std_time,spikes_mtx(:,i)); % x = std_time y = spikes_mtx
[fitresult, gof] = fit( xData, yData, ft, opts ); % Goodnes of the Fit R^2
results.STD.Coeff.a(1,i)=S.std.fitmodel.a;
results.STD.Coeff.b(1,i)=S.std.fitmodel.b;
results.STD.Coeff.c(1,i)=S.std.fitmodel.c;
results.STD.gof.sse(1,i)=S.std.gof.sse;
results.STD.gof.rsquare(1,i)=S.std.gof.rsquare;
results.STD.gof.dfe(1,i)=S.std.gof.dfe;
results.STD.gof.adjrsquare(1,i)=S.std.gof.adjrsquare;
results.STD.gof.rmse(1,i)=S.std.gof.rmse;
end preparecurvedata, power-law, exponential-decay MATLAB Answers — New Questions