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: 

Building an array for graphing

Solved!
Go to solution

Hello all,

 

First maybe this is a very silly rookie question if so my apologizes. Second this question is related to a exercise related to school, in fact i'm trying to make the program looking more fancy as asked for fun and learning purposes. Never the less my following question is NOT to get the answers easy but im looking to get in the good direction so i can solve the problem.

Ok now the the real problem.
I have made to For-Loops both 10 iterations long. This means that in this case there in total 100 iterations i need to place them in an array to be able to plot them later on an XY-Graph. For the electricians here on the forum it is an RC network and I want to plot the frequency response on a logarithmic scale. The calculations work all fine but placing the numbers in an array gives problems. The loop works such that I get 1,2,3,4,5,6,7,9,10,20,30,40 etc with corresponding voltages.
I bundel the first values 1 till 9 with their corresponding voltages, then the second iteration of the outer loop starts but th values are overwritten on the previous values. I have tried to use the function Insert Into Array (seems logical to do) but how ever i wire the function it keeps over writing the previous values.

I hope someone is willing to help me I would be really thankfull to tackle this problem and make it working to graph. 

Thanks in advance, all the best

Ray

0 Kudos
Message 1 of 20
(3,206 Views)

After you bundle the X-Y together, you are using BUILD ARRAY to make it into a 1-D array.

 

But that's an array with only one element.

 

If you bundle it, and then wire it straight thru the FOR boundary, it becomes a 1-D array automatically.

If you then wire that thru the outer FOR boundary, it becomes a 2-D array.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 20
(3,199 Views)

Thanks for your fast response CoastalMaineBi but i think i dont understand you completely. If I wire it straight thru the for boundaries I am not able to wire it to the XY Graph and second (if I understand Labview correct) the values will only be passed thru a boundary after all the iterations has been carried out? 

 

Again thanks a lot I appreciate the help

0 Kudos
Message 3 of 20
(3,187 Views)
  • Please attach the actual VI instead of a screenshot. What is your LabVIEW version?
  • I would also recommend to use a 1D complex array for xy graphing. (or a complex cluster array for multiple plots).
  • I don't think you need a formula node.
  • The 10^x should be done in the outer loop (10x less work!)
0 Kudos
Message 4 of 20
(3,184 Views)

As requested here a ZIP theres a subVI as well. I hope this works.

Im following distance education so these teachers tell you make this and have fun not a lot of explanation yet. Im having fun here with the manual and a list of requirements to get a grade. Again i dont need the answer just help on how to do the things.

Thanks again everybody

0 Kudos
Message 5 of 20
(3,179 Views)

the values will only be passed thru a boundary after all the iterations has been carried out? 

 

That's true.  By putting your GRAPH on the outside of the FOR loops, you implied that's what you want.

 

If you are using LV 2013 or later, you can set the outer tunnel mode to CONCATENATE.  That means instead of turning a series of 1-D arrays into a 2-D array, it appends every iteration, and you get a 1-D array.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 20
(3,176 Views)

Altenbach, 

I understand if I put the 10^x in the outerloop there is less work but i dont get all the x points I need. I need values for 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,,70,80,90,100 etc till 10^9. At each of those values a voltage will be calculated  because the values Xc is depending on these values.

But I have to agree there are maybe better/smarter ways to solve this, thats why i came here to learn something 🙂

0 Kudos
Message 7 of 20
(3,171 Views)

Here's a rough draft without looking at your VI yet. (The last tunnel is concatenating)

 

The f(x) just returns x at the moment. The axes are mapped logarithmically. You probably want to add a +1 in the inner loop and iterate only 9 times unless you want all these zeroes.

 

 

0 Kudos
Message 8 of 20
(3,160 Views)

CoastalMainBird,

 

First yes I use later LV version as 2013 I have 2015 Student Edition. So I tried to do your trick which sounds pretty usefull but now i get arrays that mismatch. I think I really misunderstand some important thing here in LV regarding arrays. I will get in the manual cause im getting confused LOL

0 Kudos
Message 9 of 20
(3,153 Views)

altenbach, and why are complex numbers better than clusters?

You can not name elements, you can not set different representations for x and y. Not necessary, sometimes usefull... Numerical functions work the same, will there be performance differencies?

Most often I bundle arrays of X, Y before graph, because X can be generated once and not used in Data conversion routines.

 

log xscale.png

Internal loop is 9, not 10, so that X goes ... 8 9 10 20 30....  Also +1 avoids zero that is bad for log scale...

0 Kudos
Message 10 of 20
(3,147 Views)