LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to consider different values from a two dimensional array

Solved!
Go to solution

Hi,

 

I need some help regarding one of my LabVIEW VI. I have three 2-dimensional matrices, namely Sx, Sy and P of dimension 4x4 each. I want to do the following calculation:

P(i,j)=[P(i,j+1)+P(i,j-1)+P(i+1,j)+P(i-1,j)]+1/8*[-3*Sx(i,j+1)+Sx(i,j-1)+2*Sy(i-1,j)-2*Sy(i+1,j)].

For now, you can consider any values for Sx and Sy matrices and P matrix is first initialized to have all the elements as zero.

 

 

I have done this in Matlab, but have no idea about how to do this in LabVIEW. Please help me in this regard.

 

Thanking You!

0 Kudos
Message 1 of 13
(3,432 Views)

From my understanding, you want the result of the expression you provided, to be saved in an array, right? 


0 Kudos
Message 2 of 13
(3,412 Views)

I have attached a VI. This was all I could grab from your query. 


Message 3 of 13
(3,408 Views)

Thanks for your help.

I am adding my Matlab code and this is what I want to do:



Sx=[27 0 4 19;
    19 -8 -10 16;
    20 -4 -7 9;
    27 0 2 24];


    
Sy=[22 4 -7 -25;
    7 2 -8 -12;
    -8 -5 3 5;
    -23 -9 5 13];

P=zeros(4,4);

for i=2:3
for j=2:3
P(i,j)=(Sx(i,j-1)-Sx(i,j+1)+Sy(i-1,j)-Sy(i+1,j))/8;
end
end
****

The result should come as:

P =

         0         0         0         0
         0    4.7500   -4.2500         0
         0    4.7500   -3.2500         0
         0         0         0         0

 

Will you please help me to do the same in LabVIEW.

 

N.B. Here, I have slightly changed the operation than then in the previous post.

 

0 Kudos
Message 4 of 13
(3,372 Views)

Dear Romai,

It would be much easier of you evaluate the above routine using Mathscript. Do you have one? 


0 Kudos
Message 5 of 13
(3,362 Views)

I have attached a VI. But you will need LabVIEW Mathscript Module to run it. This module embeds .m files inside labVIEW block diagram and runs it. 


Here is some detailed info about using Mathscript

http://www.ni.com/labview/mathscript/ 


0 Kudos
Message 6 of 13
(3,358 Views)
Solution
Accepted by Pranjal86
Message 7 of 13
(3,356 Views)

Yeah I do have...

Thanks a lot for your help and prompt reply!

 

 

 

 

0 Kudos
Message 8 of 13
(3,340 Views)

No problem. 


0 Kudos
Message 9 of 13
(3,333 Views)

Dear NapDynamite,

 

The mathscript did work, but if I have to do in true LabVIEW code (other then the mathscript), how should I do the same.

Here, I have attached my LabVIEW VI that I tried and obtained the result as:

               4.7500   -4.2500    
               4.7500   -3.2500

 

But not the exact result that I should obtain as:


         0         0         0               0
         0    4.7500   -4.2500         0
         0    4.7500   -3.2500         0
         0         0         0               0

(the values should come only within the interior points with zeros elsewhere, as I have shown in the Matlab code).

I will be grateful to you, if you could help me here.

 

0 Kudos
Message 10 of 13
(3,313 Views)