From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to implement this code in labview?

Dear Physicist,

 

     I apologize for mistaking you for a Student.  We've seen so many posts, like yours, that said things like "I need this now" and "I don't have time to read the Tutorials", and it invariably is a Student.

 

     So I took a look at your "solution", which might, in fact, work, but I certainly can't just "look at it and know what it is supposed to do".  That's the mark of Bad LabVIEW code.  [It would also be the mark of bad C, Fortran, or Matlab code, as well].

 

     Sometimes the issue is that the problem isn't clearly understood -- often simply restating the problem makes the solution easier to understand.

 

     I'm not certain that this is what you are trying to do, but let me give it a shot, and you can correct me:  Generate a Waveform at a certain rate for a certain number of points.  The Waveform will be piece-wise constant.  There will be two arrays, "Jump Times" and "Jump Values" -- when Time reaches Jump Time, the (constant) value of the Waveform will jump to Jump Value.

 

     If this is what you are trying to do, the solution is simple and fairly elegant.  Here is one solution:

 

     Assume you are at the the j-th Jump point, i.e. i is at least as big as Jump Times(j).  As long as i < Waveform Size and i<Jump Times(j+1), save Jump Value(j).  When this becomes false, increment j.  Exit everything when i=Waveform Size.

 

BS

 

 

0 Kudos
Message 21 of 21
(907 Views)