LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I multiply multiple matrices by Sub-Vi's?

hi,
I want to mutliply multiple matrices by just defining a sub-vi with the matrix and putting them all together graphically and get the result at the end. Could somebody give me a hint or an example? Thanks. Hein.
0 Kudos
Message 1 of 10
(2,996 Views)
I don't understand what you're looking for here? What do you mean by "just defining a sub-vi with the matrix"? Are you having problems getting data into and out of your subvis? To pass data to and from the subvis you need to assign the controls and indicators on the front panel to connection points on the icon. You do this on the front panel view by right clicking on the icon, selecting "Show Connector" and wiring the controls and indicators to the connector. Be sure to lay the connections out so that they will follow standard left to right data flow.

If this is not your problem then if you could provide more information I will try to give you some pointers.
0 Kudos
Message 2 of 10
(2,996 Views)
Hein wrote in message news:<50650000000800000031F80000-1079395200000@exchange.ni.com>...
> hi,
> I want to mutliply multiple matrices by just defining a sub-vi with
> the matrix and putting them all together graphically and get the
> result at the end. Could somebody give me a hint or an example?
> Thanks. Hein.

It's not clear whay you want to do. You can use the compound
arithmetic function to multiply multiple matrices, you don't need a
sub-vi.
I don't know what you mean by "putting them all together graphically".

Paul Cardinale
0 Kudos
Message 3 of 10
(2,996 Views)
Hi Paul,
probably I expressed not clear enough what I actually want to do. So I'm going to explain it more detailled:
I want to simulate an optical system and every optical component is defined by a 4x4-matrix. The overall matrix of the optical system is the product of all matrices. What I now want to do is defining the matrix for each optical element (as sub-vi which I can take from the functions library) an putting them together flexibly so that I get the overall matrix as product of all the single matrices.
I hope this is more clear and thank you for your help.

Regards
Hein
0 Kudos
Message 4 of 10
(2,996 Views)
Hi John,
probably I expressed not clear enough what I actually want to do. So I'm going to explain it more detailled:
I want to simulate an optical system and every optical component is defined by a 4x4-matrix. The overall matrix of the optical system is the product of all matrices. What I now want to do is defining the matrix for each optical element (as sub-vi which I can take from the functions library) an putting them together flexibly so that I get the overall matrix as product of all the single matrices.
I hope this is more clear and thank you for your help.

Regards
Hein
0 Kudos
Message 5 of 10
(2,996 Views)
It is still unclear as to where you are having problems. You will get the 4 x 4 matrices from the subvis. You then want to multiply all of these together. Is the problem that you are designing a program to model optical systems that may vary in terms of the number of elements and therefore may have different numbers of elements? If this is the case then your programming needs to be designed to keep track of how many elements you have. A state machine architecture might be a good option for this. In any event, to multiply matrices (2D arrays) just use the multiply function or compound arithmetic function in LabView.
0 Kudos
Message 6 of 10
(2,996 Views)
Hein,

Here's an example of the kind of sub-vi I think you're looking for: just a simple matrix gain block. The gain matrix is held inside the sub-vi as a numeric constant, representing the gain of a particular optical element. There's a single numeric input matrix and a single numeric output matrix, so you can easily string a bunch of these together end-to-end to represent your entire optical system.

Just setup the constant matrix values properly and save with a unique name for each particular optical element. Then as you wire from one to another, each stage will apply that element's gain, and you can quickly look at the effect of different combinations.

Just to clarify the matrix multiplication: with an input matrix A and an
internal gain G, the output will be G*A.

A future development may be to have a single top-level gain vi you always call along with an enum that specifies which optical element sub-vi gain to apply. Be sure to include a unity gain option as a quick way to simulate removal of a particular element from the optical path.

-Kevin Price
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 7 of 10
(2,996 Views)
Hi Kevin,
thank you for your immediate help. But unfortunately I've only access to LabVIEW 6.i and you sent me a version for LV7. Would you be so kind to convert it to the version I need?
Hein
0 Kudos
Message 8 of 10
(2,996 Views)
Hein wrote in message news:<506500000005000000F4D10100-1079395200000@exchange.ni.com>...
> Hi Paul,
> probably I expressed not clear enough what I actually want to do. So
> I'm going to explain it more detailled:
> I want to simulate an optical system and every optical component is
> defined by a 4x4-matrix. The overall matrix of the optical system is
> the product of all matrices. What I now want to do is defining the
> matrix for each optical element (as sub-vi which I can take from the
> functions library) an putting them together flexibly so that I get the
> overall matrix as product of all the single matrices.
> I hope this is more clear and thank you for your help.
>
> Regards
> Hein

As I indicated, you can use the compo
und arithmetic function to
multiply multiple matrices.

If the number if matices is unknown until run time, use a loop with
the multiply function and a shift register to accumulate the result.

Paul Cardinale
0 Kudos
Message 9 of 10
(2,996 Views)
Here it is again saved back to LV 6.0. Share and enjoy!

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 10 of 10
(2,996 Views)