LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting 2 arrays

Thanks altenbach

I am not an advanced programmer, just started learning LabVIEW so just worked with some examples, mistakes are very common in everyones life.

anyhow thanks for your suggestions.

0 Kudos
Message 21 of 52
(1,811 Views)

Thanks everyone

I had made a mistake in the code thats the reason i got it wrong.

Thanks very much for ur support

 

 

0 Kudos
Message 22 of 52
(1,795 Views)

Veeru wrote: I am not an advanced programmer, just started learning LabVIEW so just worked with some examples, mistakes are very common in everyones life.
You did not make mistakes with the FOR loop here, its' just that there are better ways to do certain tasks and it is best to learn better ways early in the LabVIEW experience. That's why I am pointing out these things.:)
 
First priority is to get the correct results no matter what, and after that you can think of ways to simplify the code to improve code readability and code efficiency. LabVIEW allows you to write very functional code with very few steps. Autoindexing and polymorphism is a cornerstone of efficient coding, so that's something you should learn early. Please study my image.
 
With a bit of experience, everybody can be Tiger Woods of LabVIEW and do the same thing in fewer strokes. Your frame #2 was just one of those triple bogeys that every beginner makes while learning. 😄
 
A big source of potential coding errors is your stacked sequence structure, because it is nearly impossible to verify where the data flows between the frames. All these sequence locals break up the dataflow and you need to constantly flip between frames to see what's connected to what and to verify that no wires are crossed. 80%+ of all code is hidden at any point in time. It is like playing golf in dense fog! There is no reason to sequence your code. Dataflow ensures that nodes only execute once data has arrived at all inputs, so in this case the sin, cos and atan will execute at the correct time and anything after it will wait until they produce output.
 
We have seen much worse code. For an illustrative experience, browse some of the code posted in the Rube Goldberg Thread.
0 Kudos
Message 23 of 52
(1,781 Views)
Thanks very much altenbach
0 Kudos
Message 24 of 52
(1,766 Views)

Hi all,

I am having a somewhat similar problem with arrays. I'm trying to do an exercise from the NI online tutorial and having a hard time finishing it. I can't get the code to work and plot the graph. Here is how the actual problem was stated:

"Build a VI that generates a 2D array of three rows by 10 columns that contains random numbers. After generating the array, index each row, and plot each row on its own graph. The front panel should contain three graphs".

Please I'll appreciate it if somebody can help me out here.

Thanks.

0 Kudos
Message 25 of 52
(1,728 Views)
Maybe you can show us how far you got?
 
If you cannot solve the problem, it is time to go over the tutorial once more. I am pretty sure everything you need to know is covered in the tutorial. 😄
 
What specific road blocks are giving you problems?
0 Kudos
Message 26 of 52
(1,717 Views)

Altenbach,

Build a VI that generates a 2D array of three rows by 10 columns that contains random numbers. After generating the array, index each row, and plot each row on its own graph. The front panel should contain three graphs".

I'm not infront of my computer so I'll just try to explain it.

Looking at the question, I generated the 2D array with two For loops using random # function.

I didn't add any code for indexing since the For loop is auto-indexed and zero based.

Next, I connected the array subset function to separate the three rows. (is this correct function here or the build array function)  

After adding the array subset function, I then connected it to the bundle function. This was where the main dificulty was. I couldn't connect the data that emerged to the waveform graph. It keep showing erroneous wiring between the bundle function and waveform graph.

0 Kudos
Message 27 of 52
(1,702 Views)


Mbdeck wrote:
Next, I connected the array subset function to separate the three rows. (is this correct function here or the build array function)  
To get rows, you use index array. specify the  one index and leave the other index unwired and you'll get and entire row (or column, depending on which index you wire. If you wire both indices, you'll get a single element.). You can resize the index array terminal to get several rows or columns.


Mbdeck wrote:
After adding the array subset function, I then connected it to the bundle function. This was where the main dificulty was. I couldn't connect the data that emerged to the waveform graph. It keep showing erroneous wiring between the bundle function and waveform graph.

Waveform graphs accept 1D arrays, so just wire each row to its graph terminal. No bundle needed (don't use an xy graph!).
  1. create your 2D array.
  2. Use a single "index array" resized to three outputs.
  3. Get the three rows as described and wire each to a graph terminal.

Voila!

0 Kudos
Message 28 of 52
(1,699 Views)

Thanks and one more thing,

All three graphs should be in one graph indicator,... right?. Or are you talking about three separate graph indicators here? 

0 Kudos
Message 29 of 52
(1,695 Views)
NO!


Mbdeck wrote:

...and plot each row on its own graph. The front panel should contain three graphs".


If you want all plots on the same graph, you would just wire the 2D array (transpose if needed).

0 Kudos
Message 30 of 52
(1,687 Views)