Ordinary Least Squares Method program
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have to make form scratch a program that applies the Ordinary Least Squares Method to a set of data (matrix D) and the base functions( elements of the vector b), but the program isnt working, I think it's not creating the inline functions version of the base functions that I need to calculate the value of those functions on some points, but I don't know how to correct that:
function g=mmq(D,b)
[~,tc]=size(D);
syms x;
for i=1:length(b);
b(i)=inline(b(i));
end
l=1;
h=1;
A=zeros(length(b),length(b));
while l<=length(b);
for c=1:length(b);
while h<=tc;
A(l,c)=A(l,c)+(b(l)(D(1,h))*b(c)(D(1,h)));
h=h+1;
end
end
l=l+1;
end
Y=zeros(length(b));
for k=1:length(b);
while r<=tc;
Y(l)=Y(l)+(b(k)(D(1,r))*D(2,r));
r=r+1;
end
end
Y=Y';
C=A\Y;
for u=1:length(C);
g=g+(C(u)*b(u));
end
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Function Creation 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!