LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to sort a 2D array and then using the index corresponding max value

Hello Everybody,

 

I am a beginner in Labview. I have a small circuit with MOSFET transistors where I command the duty cycle and I acquire the output power. So, I use a for loop (from 1 to 100%) in Labview to sweep the range of the duty cycle and I measure the output power and build an array (with 2 columns: the value of the duty cycle and the power associated) and a graph. I obtain the value of the maximum power with the array function max&min.

 

But I would like to obtain the value of the duty cycle corresponding to the maximum power and then block my circuit at this value, in a very short time. 

I am trying to manage it by using a formula node and writing C code but as NI says, it is slower if I use a formula node instead of graphic programming, so that's why I am asking to you if there is a graphic function to solve my problem.

 

Thank you very much,

 

Anthony

0 Kudos
Message 1 of 11
(4,238 Views)
Unless I am really missing something here, you will notice that Array max & min also gives you the index and you can simply index the duty cycle array.
Message 2 of 11
(4,237 Views)

Oh yes that's true. I am sorry.

 

Thank you!

0 Kudos
Message 3 of 11
(4,228 Views)

Antho wrote:

Oh yes that's true. I am sorry.

 

Thank you!


No need to be sorry. The polymorphism that Darin pointed out is one of the fun/mysterious parts of LV. There are few amoung us that keep track of which data types are supported by which operators so the more experienced will "just try it out". There have been many times when I was faced with a code challenge that "would be so much easier if..." and to my suprise it actually worked!

 

Sea Story Time!

 

One of my earliest G-Daddies was Jay Grassel (now with NI) who taught me, "If you don't know how an operator works, do a ctrl-n and try it out!"*

 

Ben

 

* ctrl-n = Open new VI

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 11
(4,192 Views)

@Ben wrote:
 No need to be sorry. The polymorphism that Darin pointed out is one of the fun/mysterious parts of LV. 

 
I could hardly fail to disagree with Ben less...Smiley Very Happy 

 

0 Kudos
Message 5 of 11
(4,180 Views)

Thank you for the advice, it's better now to understand the functions.

 

But I have another question about the array max&min function. Is there a mean to obtain the value of the index corresponding to half of the value of the maximum. Because I have Pmax and the index, and I would like the value of the index for Pmax/2 too.

 

Thank you

 

Anthony

0 Kudos
Message 6 of 11
(4,168 Views)

Take the value of Pmax/2 and subtract it from all values in our array and take the absolute value. Then use another Array max min an look for the minimum since that will be the value closest to Pmax/2.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 11
(4,164 Views)

Yes it works! Thank you very much!

 

Anthony

0 Kudos
Message 8 of 11
(4,159 Views)

Be aware that the "Min Max" vi returns the maximum value from the array irrespective of the column.

So if you want the maximum Power, I would first get the column with Power data and then use the "Min Max" vi.

But not on the complete 2D array.

If one day you're power will be less than 100W, the suggest solution will return 100, not from the power but from 100% duty cycle!

Watch out!!!

Message Edited by Alain S on 08-13-2009 05:41 PM
0 Kudos
Message 9 of 11
(4,158 Views)

Ben wrote:

 

One of my earliest G-Daddies was Jay Grassel (now with NI) who taught me, "If you don't know how an operator works, do a ctrl-n and try it out!"*

 


 

I have been meaning to do this for a while, but Ben's post finally motivated me to start a new thread with this in mind.  It is my LV equivalent of the Word of the Day calendar.

Message 10 of 11
(4,137 Views)