Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

I am trying to fit some data but getting the wrong coeffs!

1 vue (au cours des 30 derniers jours)
Nathan
Nathan le 19 Jan 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
So I am trying to find some coeffs with Matlab.
Here is my code:
zdata = [2,8,12,20,26,40,50,59,68,79,82,92]';
ndata = [2,8,14,20,26,50,74,76,94,118,126,143]';
adata= [zdata+ndata];
bdata=[28.3,127.6,216.7,342.0,447.7,783.9,1050.0,1124.4,1320.7,1559.4,1636.4,1783.9]';
%define av term
av = adata;
%define as term
as = -adata.^(2/3);
%Define ac term
ac = -[(zdata.^2-zdata).*adata.^(-1/3)];
%Define aa term
aa = -[(adata-2*zdata).^2.*adata.^(-1)];
%Define ap term
ap = [adata(1).^(-1/2),adata(2).^(-1/2),adata(3).^(-1/2),adata(4).^(-1/2),adata(5).^(-1/2),adata(6).^(-1/2),adata(7).^(-1/2),0,adata(9).^(-1/2),0,adata(11).^(-1/2),0]';
X= [av as ac aa ap];
a = X\bdata
When run it outputs:
a =
16.331878598287652
19.691560324192896
0.768989561715635
23.162609278749475
27.946210266012489
The real values of the coeffs are
15.85
18.34
0.71
23.21
12.00
So not so far off, except the last one!
Is there a better way of doing this?
following the code above I am trying to fit my data to
bdata=a(1)*av+a(2)*as+a(3)*ac+a(4)*aa+a(5)*ap
Where av, as, ac, aa, ap are defined.
How can I do this using least square fit? Thanks!

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by