LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

one matrix subtracted by another gives a scalar?

Solved!
Go to solution

Hi,

I am implementing an algorithm, Recursive Least Squares Method. Something went wrong with matrix subtraction. That node lays below the context help gives a scalar. It should be a matrix, anyway.

1.jpg

How can I fix it?

 

Thanks in advance.

 

Chuan

0 Kudos
Message 1 of 9
(5,131 Views)

For anyone interested in algorithm .

1.Pick 0<gamma<=1, delta>0, m>=0, N>=1

2.Set w=0, p=0, and Q=delta^-1 * I. Here w and p are (m+1)*1 and Q is (m+1)*(m+1)

3. For k=1 to N compute

{

u=[x(k) x(k-1) ... x(k-m)]T

r=Qu

c=gamma+uT r

p=gamma p+d(k) u

Q=1/gamma*(Q-r * rT /c)

w=Q p

}

 

The errors occured when I was trying to compute (Q-r * rT /c).

0 Kudos
Message 2 of 9
(5,113 Views)

If you want help with your code, you need to supply us with your code.  A "picture" that (a) shows only some of the code, (b) is not easy for us to modify (to make it easier to understand what it does), and (c) is not executable doesn't provide enough information for us to really help you.

 

I can tell you that subtracting two 3x3 matrices gives a 3x3 matrix, not a scalar.  So if you are, indeed, doing such a subtraction and getting a scalar, you are probably not doing "what you think you are doing".  I'd want to execute (and watch) your code and figure out where you made the mistake, but I need you to attach your VI.

 

Bob Schor

0 Kudos
Message 3 of 9
(5,107 Views)
0 Kudos
Message 4 of 9
(5,103 Views)

What problem is "Recursive Least Squares" supposed to solve?  Don't tell me the algorithm, tell me the problem (i.e. "Find the coefficients of an N-degree polynomial that best fits M data points", or something like that).

 

Bob Schor

0 Kudos
Message 5 of 9
(5,100 Views)

It's to find the best coefficients for an adaptive filter. 

0 Kudos
Message 6 of 9
(5,092 Views)
Solution
Accepted by topic author Dirichlet123

OK, so somehow the Feedback Node messes up Matrix code -- good discovery/observation.  Thanks for sending the "simple example".  Also, thanks for providing the context for this code.

 

Bob Schor

Message 7 of 9
(5,049 Views)

Hi Dirichlet,

 

why did you create another thread for the very same problem?

Why didn't you stick with this thread?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(5,033 Views)

Sorry, I think this one might be too messy and complicated. And I find the problem is just the feedback node.

 

Best regards,

Chuan

0 Kudos
Message 9 of 9
(5,028 Views)