mldivide test doesnt work.
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (2)
Mischa Kim
on 2 Mar 2014
Edited: Mischa Kim
on 2 Mar 2014
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
0 Comments
Image Analyst
on 2 Mar 2014
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.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!