From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

I want to record the output and put all values into a array, but fail to do

Solved!
Go to solution

I listed in the picture, when i hit run, no error, but I didnt get anything, what's my logic pitfall ? 😞

Download All
0 Kudos
Message 1 of 8
(2,497 Views)

It appears that you are using Replace Array Subset (which is good), but the array you are replacing (Output) is empty. Replacing an element in an empty array has no effect.  From the Detailed Help for Repalce Array Subset:

 


If any index is negative or larger than the corresponding dimension in n-dimension array the function has no effect.


 

 

Initialize Output to be the same size as Input Array or to have 11 elements, whichever is smaller. If you move Input array to the right of the for loop and use autoindexing, the Index array is not required.  If Input Array and Output Array will always be the same size, you do not need Output at all. Initialize the array outside the loop and wire it to a shift register.

 

I am not sure what you are doing but a graph might be more appropriate than a chart since you write the complete array on each iteration.

 

Lynn

0 Kudos
Message 2 of 8
(2,481 Views)

thank you, to use Replace Array Subset, I have to unitialze values, before that, all values are gray, but now, thing is worse or I should say i didnt know how to eliminate my Output array and replace it with shift register...T_T

 

 

0 Kudos
Message 3 of 8
(2,464 Views)
Solution
Accepted by topic author ivy037

Here is the way to connect it via a shift register.  Note that I also moved Input Array outside the loop and used autoindexing. I also used Initialize Array rather than an array constant.  There is nothing wrong with using an array constant, but using Initialize Array allows the program to adapt to the size of Input Array.

 

As noted on the diagram I could not hook up the data wire from the Fuzzy Controller.vi because I do not have that subVI.  You will need to make that connection before you test.

 

Lynn

0 Kudos
Message 4 of 8
(2,456 Views)

This is called professionalism. Compare my code with yours, I feel I have a long way to go....

 

thanks, Lynn, but last question, I redo everything according to your code and hit run, the output is all zero... This is weird. If my fuzzy system is not that good, it cannot be all zero, no?

 

Also, every time I open the code, I need to manually initialize all values in the input array, this is annoying. Can LabView remember all my values? In Matlab, All I did is just write input = [7 5 6 7 8 5 3 4 5...etc]

 

0 Kudos
Message 5 of 8
(2,448 Views)

Context-click on the Input array control on the front panel and choose Make Current Values Default from the pop-up menu. Then save the VI.  That will preserve the data.  You can still change it manually any time you want to run with different data.

 

Your code is not bad.  I have seen much worse.  If you have not done so, I recommend that you spend the time to work through the on-line Getting Started tutorials.  Also check out the LV Style Guide.

 

Lynn

0 Kudos
Message 6 of 8
(2,412 Views)

Make Current Values Default ---- I learned another technique!!

 

Thank you!!

0 Kudos
Message 7 of 8
(2,397 Views)

Tip 1: While programming, always keep the Context Help window visible.  It has lots of useful information.

 

Tip 2: Explore the menus.  You might be surprised at what you can find there.

 

Lynn

0 Kudos
Message 8 of 8
(2,392 Views)