curve fitting using least square method form equation , y = (1 + a sin(2x))/ (b + cx^2) where a, b, c are unknown real constants.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Parva
el 7 de Feb. de 2023
Comentada: John D'Errico
el 7 de Feb. de 2023
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)
0 comentarios
Respuesta aceptada
John D'Errico
el 7 de Feb. de 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.
1 comentario
John D'Errico
el 7 de Feb. de 2023
Since you accepted my answer, I hope you saw the error you made. It should have been aparent when you did what I said.
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!