LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos
Message 1 of 15
(3,140 Views)

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
0 Kudos
Message 2 of 15
(3,134 Views)

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

0 Kudos
Message 3 of 15
(3,128 Views)

Hi fairy,

 

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

check.png

Obey the POLYMORPHISM! 😄

 

@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
Message 4 of 15
(3,103 Views)

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. 

 

 

0 Kudos
Message 5 of 15
(3,082 Views)

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
Message 6 of 15
(3,074 Views)

Thnx all of u.. it realy works :).

 

 

0 Kudos
Message 7 of 15
(3,024 Views)

hi GerdW!

From where i can find max/min vi?

0 Kudos
Message 8 of 15
(3,022 Views)

fairy55 wrote:

From where i can find max/min vi?



Try the comparison palette.  (Min&Max).

0 Kudos
Message 9 of 15
(3,020 Views)

hi!

i have another problem now.

r1= 1 2 3 

       4 5 6

r1(:)= 1

          4

          2

          5

          3

          6

how can it possible in l.v?

thnx

0 Kudos
Message 10 of 15
(3,011 Views)