Borrar filtros
Borrar filtros

code to implement continuous least square

7 visualizaciones (últimos 30 días)
sam2021
sam2021 el 28 de Feb. de 2020
Respondida: Dinesh Yadav el 2 de Mzo. de 2020
Write Matlab code to implement the continuous least squares method of finding the best-fit polynomial of degree n for a given function f on the interval [a, b]. Again, you may not use the Matlab command polyfit or anything similar. Populate a matrix and vector and solve the resulting matrix-vector equation. Once you have solved the matrix-vector equation, you may then use the polyval function. The inputs should be contained in a Matlab function file called clsin.m, which should contain, for example,
function [n f a b] = clsin()
syms x;
n = 5;
f = sqrt(x);
a = 0;
b = 1;
end
In this example, we are trying to fit a polynomial of degree 5 to the function f(x) = x on the interval [0,1]. Your output should be a picture, showing both the original function f and its least squares polynomial approximation, both only on the interval [a, b]. The Matlab command fplot (in the symbolic toolbox) may prove to be handy.
I am really struggling with this problem. We cannot use polyfit or anything similar. Any help on this problem would be appreciated.

Respuestas (1)

Dinesh Yadav
Dinesh Yadav el 2 de Mzo. de 2020
Hi,
Kindly go through the following doc on methods to solve linear least squares problem using matlab without using polyfit.
Hope it helps.

Categorías

Más información sobre Mathematics 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!

Translated by