mldivide test doesnt work.

1 次查看(过去 30 天)
Derck
Derck 2014-3-2
Hello,
For a research project I have to find the coefficients corrsponding to the value of importance of the previous days.
for example:
_a = rand(1024,4);
b= rand(1024,1);
t=a\b;
btest=a*t;_
where t would give me the coefficients. However when I do the test by computing btest and compare it with b, this gives me a completely other result. How is this possible? Am I doing something wrong or is this because b is calculated with approximations by matlab?
Thanks!

回答(2 个)

Mischa Kim
Mischa Kim 2014-3-2
编辑:Mischa Kim 2014-3-2
Derck, you are working with an overdetermined system: 1024 equations in 4 unknowns. Chances that the system results in an exact solution are slim.
Try, instead (to get confidence in MATLAB)
a = rand(1024,1024);
b = rand(1024,1);
t = a\b;
btest = a*t;
norm(b-btest,inf)
ans =
8.495634751248815e-13

Image Analyst
Image Analyst 2014-3-2
btest won't equal b. I don't know if that's what you're thinking, but it won't happen unless you have perfect data to begin with. You're doing an ordinary least squares solution so your solution with be a nice smooth analytical line that goes nicely between the random points. Your test arrays are particularly badly chosen - in fact I don' think you could have possibly chosen worse sets of data . You're going to have no sensible equations that map a bunch of random values into another bunch of random values with a simple weighted sum of the input values.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by