LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

nested for loop

hello

how can i implement this code in labview. i am new to labview, so plz if u design a vi of this code.

for i=1:m
c = (i-m/2);

for j=1:n
d = (j-n/2);

N1(i,j)=exp(-(c^2+d^2)/c1^2);
end
end

wher m is num of rows and n is number of column and c1 is a constant

thnx

kitty

0 Kudos
Message 1 of 9
(6,290 Views)
New to labVIEW is not a problem. But you seem to want to learn something. By us giving you the vi, you learn nothing.
Use a FORloop. And attach your variable m to the N selector. In that for loop place another for loop, attach your n to the N selector. Every value that is calculated in the inner for loop can be brought to the outside and will build into a 2D array with n colums and m rows. No doubt you can figure out the rest yourself. Try it. If further questions, reply, show us what you got an we will help if you're stuck
Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 2 of 9
(6,283 Views)

Here's a quick framework for you to start with.  I left out most of the math.

 

Some things to notice:

  1. The i terminal starts with 0 and counts up for each iteration.  Since you want your math to start with 1, you need to increment.
  2. See the autoindexing out of the FOR loops?  That's what is building up your 2D array.

 

Since you claim to be new, you might want to check out some of the online tutorials.

LabVIEW Basics

LabVIEW 101


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 9
(6,277 Views)

thnx dears.

i think i get confuse in no time .:)

but after posting question i tried and designed a vi that is giving me correct result.

here is it.

thnx 🙂

 

 

is it correct?

0 Kudos
Message 4 of 9
(6,249 Views)

now plz tell me one thing that how can i find a*b and a.*b.

the aXb vi inlinear algebra is producing wrong result 😞

0 Kudos
Message 5 of 9
(6,247 Views)

The results are correct for the inputs given and the current code 😉

 

What is the purpose of the empty matrix you have wired to the FOR loop? Since it is empty, it will force zero iterations and your loop does not produce any data. remove it!

Why are your diagram and front panels maximised to the screen??? That's just annoying...

0 Kudos
Message 6 of 9
(6,234 Views)

sorry. i dont understand what do u mean by block daiagram maximised to screen?

0 Kudos
Message 7 of 9
(6,175 Views)

My monitor is 2560x1440 pixels and your code on the diagram is about the size of a postcard. If I open your VI, the front panel and diagram windows are maximised to the screen, filling every single pixel with mostly white or grey non-information.

 

As a labview programmer, my brain operates in parallel and I typically would like to look at more than one window at a time. The windows should not be larger than needed to display the relevant information.

 

Thanks!

 

(This same issue is the most annoying feature of the new windows 8 optimized programs that now open fullscreen (skype, document viewer, player, etc.) I use the windows 7 version of skype and similar tools (acrobat viewer, mediaplayer, etc.) for the other programs)

0 Kudos
Message 8 of 9
(6,162 Views)

@kitty14 wrote:

now plz tell me one thing that how can i find a*b and a.*b.

the aXb vi inlinear algebra is producing wrong result 😞


hi kitty!

From my experience aXb.vi is working correctly compared to this reference

 

 

outer cross product

 

 

 

 

Alex

0 Kudos
Message 9 of 9
(6,130 Views)