Ordinary Least Squares Method program
조회 수: 9 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!