"John" wrote in message <ijitf5$p05$1@fred.mathworks.com>...
> I have to solve a problem where I am given one equation aX+bY+c=D. I am given D, X, and Y in the form of 100 samples of data for each, and using that I am supposed to determine a,b,c.
>
> my code takes the form of
> syms a
> syms b
> syms c
> for z=3:3:length(D)
> [a,b,c]=solve('D(z)=a*X(z)+b*Y(z)+c', 'D(z1)=a*X(z1)+b*Y(z1)+c', 'D(z2)=a*X(z2)+b*Y(z2)+c'
> end
>
> but the answers I get are in terms of the variables with a combination of the z z1 and z2 parts of it, not an actual number.
Hi,
If you are trying to solve your problem symbolically, You may get numbers after eveluating the final formulae. However, if you have column vectors of numerical data, you may proceed in the following way:
A = [X(z) Y(z) ones(length(X(z),1))
X(z+1) Y(z1) ones(length(X(z1),1))
X(z+2) Y(z2) ones(length(X(z2),1))];
B = [D(z);D(z1);D(z2)];
p = A\B;
a = p(1);
b = p(2);
c = p(3);
Maybe, I am wrong, however, for numerical data it should work.
Mira
