curve fitting using least square method form equation , y = (1 + a sin(2x))/ (b + cx^2) where a, b, c are unknown real constants.

3 visualizzazioni (ultimi 30 giorni)
hi, this is the question:This file contains data points (xi , yi) where xi is the i-th entry of array x and yi is the i-th entry of array y. It is known that the dependence between y and x is of the form equation (1) , y = (1 + a sin(2x))/ (b + cx^2) where a, b, c are unknown real constants. It is known that all data points (xi , yi) satisfy equation (1) up to small measurement errors. Clear the denominator in equation (1) and consider plugging in each data point. This leads to an overdetermined system of linear equations. Use Matlab's least-squares solver \ to find the least-squares approximate solution to this overdetermined system of linear equations. You must not use any for-loops or while-loops.
I don't know what I am doing wrong in this code:
clear; close all; format compact
load a3.mat;
n = length(x);
A = [sin(2*x(:)), x(:).^2, ones(length(x),1)];
b = y(:);
sol = A\b;
% Extract the coefficients a, b and c
a = sol(1)
c = sol(2)
b= sol(3)

Risposta accettata

John D'Errico
John D'Errico il 7 Feb 2023
Hint (since this is homework): What is your model? WRITE IT DOWN. What happens when you mutiply by the term in the denominator? WRITE IT DOWN.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by