05-18-2013 02:20 AM
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!
Solved! Go to Solution.
05-18-2013 06:55 AM
From my understanding, you want the result of the expression you provided, to be saved in an array, right?
05-18-2013 07:18 AM
I have attached a VI. This was all I could grab from your query.
05-20-2013 04:23 AM
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.
05-20-2013 06:20 AM
Dear Romai,
It would be much easier of you evaluate the above routine using Mathscript. Do you have one?
05-20-2013
06:27 AM
- last edited on
01-28-2025
12:57 PM
by
Content Cleaner
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/
05-20-2013 06:29 AM
Here you go.
05-20-2013 07:38 AM
Yeah I do have...
Thanks a lot for your help and prompt reply!
05-20-2013 08:29 AM
No problem.
05-21-2013 02:16 AM
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.