03-15-2017 03:24 PM - edited 03-15-2017 03:26 PM
@Alexander_Sobolev wrote:
altenbach, and why are complex numbers better than clusters?
Well, I like it better, because it simplifies the code, especially when e.g. interactively building a graph in a shift register. Graphing in the complex plane is very natural to me. Also operation such as shifting and rotating can be done on complex data without the need for any explicit trigonometry.
To each his own. 😄
Yes, if you don't have the concatenating tunnel, here's what I would do.
03-15-2017 03:27 PM
Concengating the outer loop did the trick
This is how the graph should look like
Alexander youre right i should avoid a =0 with my code as 0 with log scales is undefined. The other loop where you can get X^0 = 1 is good as the scale starts with 1.
I appreciate all the comments here because i think I can improve my code a lot. And as extra thing now its time to add another plot on the same graph.
LV is really a different way of programming IMHO im used to Matlab, C and VB but this is quite different.
Thanks everybody
03-15-2017 03:30 PM
Here's a piece of advice for a beginner working on this stuff.
BREAK IT DOWN.
Make your first task generating a list of the FREQs you want: 1-9, 10-90, 100-900 etc.
Make that into ONE vi with an output of the frequencies.
Work on that until it works correctly, 100% exactly.
Save that VI as "Generate Frequencies" or something.
THEN FORGET ABOUT IT.
USE it in another VI. Remember that a FOR loop will auto-index an input array.
So call that GEN FREQS vi, and put a FOR loop to use the array.
for each iteration, you will have a value from the array, in order.
There's where you calculate your Xc.collect the single Xc values into a separate array.
Then bundle the FREQS array (as X) and the Xc array (as Y) and feed that to a graph.
LV is great for doing that because you can make a SubVI and work on it BY ITSELF until it works, then use it somewhere else.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-15-2017 03:45 PM
OK, I guess you got it sorted out. A few comments:
03-15-2017 03:55 PM
To All,
Thanks a lot for all the help and great comments to improve my code. As you all have seen im a rookie but start to like it (who know you'll see me more often here 😉 ). I will all the suggestions and improve them as far I can do.
Its nice to see there are so many people who try to help a rookie without having trolls etc.
All the best,
Ray
03-15-2017 04:30 PM - edited 03-15-2017 04:35 PM
Here's a quick cleanup (LV 2015), see if you still recognize your code. 😄
(Yes, certain other parts could be wrapped into subVIs. Once you expand the code, use an event structure and create one event case for value changes of all the four controls. Then create other events for the new functionalities as needed. The calculation only needs to be done once when the program starts and whenever one of the controls changes. The rest of the time it can just wait for the next event.)
03-15-2017 04:59 PM - edited 03-15-2017 04:59 PM
Also note that since the ramp is just cosmetic here, all you need is to generate an logarithmic ramp from 1 to 1G (using Ramp Pattern) and you are all set. No need for loops and math and the points are actually spaced equally on the log scale. 😄
03-15-2017 05:59 PM
Heheheh lol yeah i almost don't recognize my code anymore (if i still can call it my code). Hmmm tomorrow im going to fix this I think. Thanks I learn a lot like this. Im planning to add some extra things indeed and could use this function in front of the while loop. It seems like i was trying to reinvent the wheel 🙂
Cool
03-16-2017 08:48 AM
Hey Altenbach,
Does your code works as well when one wants to graph two plots? Or do I need to apply other tricks?
03-16-2017 11:09 AM
@Ray1981 wrote:
Does your code works as well when one wants to graph two plots? Or do I need to apply other tricks?
Yes, it can easily be expanded onto multiple plots. If different event cases update different plots, you should keep the plot data in a shift register and replace the relevant plot with new data.
If one plot is a complex array, you need to create a 1D cluster array, i.e. an array where each element contains a cluster containing a 1D complex array. You can use this function, where each input is a complex array and the output can be wired directly to the graph terminal. Try it!