cancel
Showing results for 
Search instead for 
Did you mean: 

if condition

fairy55
Member

if condition

hi

kindly tell me how can i implement this code in l.v. i do not know how to use if in l.v

here is the code:

for i=1:m
for j=1:n
if b11_mat(i,j)<=lum(i,j)
b11_mat(i,j)=lum(i,j);
end
end
end

 

thnx

Fairy

14 REPLIES 14
Ranjeet_Singh
Active Participant

Re: if condition

Do one thing, Post your C code. I will convert it into LabVIEW.

 

This is bit confusing.

 

Thanks

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Brett_J
Member

Re: if condition

Message contains a hyperlink Message contains an image

Hi Fairy,

 

I think this is basically what you are trying to do with your code.

 

The case structure is generally a pretty good replacement for the if statement.

 

Code1.png

 

You can find a little more about the case structure here.

The other neat thing is the for loop automatically indexes through the arrays for you.

 

Good Luck,

Brett

GerdW
Knight of NI

Re: if condition

Message contains an image

Hi fairy,

 

when all you need is the MAX then you should use the MIN/MAX function:

check.png

Obey the POLYMORPHISM! Smiley Very Happy

 

@Brett:

Using the Select function is more easy to read than a CASE structure in such a simple VI...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Mystogan
Active Participant

Re: if condition

Message contains an image

Hi,

I think Gerd has shown you very effective code for your request,

here I just add the possibility to control the value m and n.

 

 

forum.png

 

regards,

Yan. 

 

 

GerdW
Knight of NI

Re: if condition

Message contains an image

Hi Yan,

 

you don't need FOR loops for that, ArraySubset is sufficient too:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Highlighted
fairy55
Member

Re: if condition

Thnx all of u.. it realy works Smiley Happy.

 

 

fairy55
Member

Re: if condition

hi GerdW!

From where i can find max/min vi?

altenbach
Knight of NI

Re: if condition

Message contains a hyperlink

fairy55 wrote:

From where i can find max/min vi?



Try the comparison palette.  (Min&Max).

fairy55
Member

Re: if condition

hi!

i have another problem now.

r1= 1 2 3 

       4 5 6

r1(Smiley Happy= 1

          4

          2

          5

          3

          6

how can it possible in l.v?

thnx