LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

C code to labview array implementation

Solved!
Go to solution

Hi,

 

 Is it possible to change this C code into labview nested array with 2 inputs ? Smiley Sad

 

Thank you.

 

0 Kudos
Message 1 of 13
(5,079 Views)
Solution
Accepted by montu.dada

Of course it is!

 

This code:

for(i=0;i<height;i++) {

      for(j=0;j<width;j++) {

            if(a[i][j]>240) {

                 a[i][j]=255;

             }

            else {

              a[i][j]=0;

            }

       }

 }

Could look like this:

ccodefirstpart.png

 

You should be able to finish the rest Smiley Happy

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
Message 2 of 13
(5,064 Views)

Thankx Craig,

 

 Im new to labveiw so i'll give my best shot to complete and upload the VI here .Can you please help to review this final VI?

 

Thankx in advance. (Y)

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

That is a VI snippet.  You can drag the image to your LabVIEW block diagram and you'll have the code.  (Assuming you have LV 2013 since the VI was created as a 2013 version.)

0 Kudos
Message 4 of 13
(5,033 Views)

montu.dada wrote:

 Is it possible to change this C code into labview nested array with 2 inputsSmiley Sad 



What is the second input??

 

Here's a no-loop solution (assuming a single input of a 2D array). 😄

 

 

Or this (a little less universal. only works for unsigned integers)

 

 

 

Download All
Message 5 of 13
(5,029 Views)

Now,

  I couldn't figure it out to deal with if statements. Can tyo suggest me about this section please?

 

for(j=60;j<120;j++) {

   

     if(a[30][j+1]!=a[30][j]) {

         if(a[30][j+3]!=a[30][j]) {

             h_count=h_count+1;

          }

      }

}

 

Regards.

montu

0 Kudos
Message 6 of 13
(4,997 Views)
You've already marked the question as solved. Why do that and ask basic question such as what is an if statement in LabVIEW. Click on the Options button to remove what you marked as the solution.
0 Kudos
Message 7 of 13
(4,989 Views)

@montu.dada wrote:

Now,

  I couldn't figure it out to deal with if statements. Can tyo suggest me about this section please?

 

for(j=60;j<120;j++) {

   

     if(a[30][j+1]!=a[30][j]) {

         if(a[30][j+3]!=a[30][j]) {

             h_count=h_count+1;

          }

      }

}

 

Regards.

montu


You need 2 index arrays and a Equal comparison.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 13
(4,985 Views)

it that what you mean?

 

Thankx.

0 Kudos
Message 9 of 13
(4,974 Views)

How can we initialize the for loop to 60?

 

thankx.

0 Kudos
Message 10 of 13
(4,952 Views)