How to do weighted least square rgression?
    17 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hello
I want to fit an exponential curve to my data using MatLab. Could you please guide me how can I write a code to fit this through weighted least square reression? The weight matrix is as follows. I could not find any instruction or sample code to do so!
weight=[18.5204555170429; 24.8007492441765; 21.4204953742493; 12.0007299687922; 5.17482448096073;2.24987321147564]
x=[1.5;4.5;7.5;10.5;13.5;16.5]
y=[0.466132177250491;0.307694759285704;0.477550022494737;0.489169081512968;0.439027124884140;0.306938063199741]
Thanks
0 commentaires
Réponses (1)
  Star Strider
      
      
 le 6 Oct 2023
        
      Modifié(e) : Star Strider
      
      
 le 6 Oct 2023
  
      weight=[18.5204555170429; 24.8007492441765; 21.4204953742493; 12.0007299687922; 5.17482448096073;2.24987321147564];
x=[1.5;4.5;7.5;10.5;13.5;16.5];
y=[0.466132177250491;0.307694759285704;0.477550022494737;0.489169081512968;0.439027124884140;0.306938063199741];
mdl = fitlm(x,y, 'Weights',weight)
figure
plot(mdl)
grid
I assume that you want to do a linear regression, since you did not mention a nonllinear model of  any sort.  
.
Voir également
Catégories
				En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





