09-06-2022 07:14 PM
Hi, I have a bit of code converting a 2D array into a 1D array of clusters. For some reason, when I write it, the output is not of the appropriate format. But a snippet I copied out of someone else's code that does the exact same thing does run.
Can anyone spot the issue with my version? What am I missing?
Working version:
Non-working version:
Please see attached vis.
Solved! Go to Solution.
09-06-2022 07:18 PM
I could not open the VI since you shared it in LV22.0 (which not many professionals would have at their disposal).
Anyway, from experience I could guess the error is due to the number of cluster elements configured in Array to Cluster primitive.
Right click >> Cluster Size... >> Number of elements in the cluster
Match the value as defined in the original VI and it should work.
09-06-2022 09:18 PM
The cluster size needs to be set to 2 for an XY graph.
09-07-2022 12:49 AM - edited 09-07-2022 12:49 AM
For the future, the way to analyze a problem like this is to hover with the cursor over the broken wire, which should show you the difference between the data types. If you also open the context help window (Ctrl+H) and hover over the different sides of the brake, you should see the type for each side in the context help window. That should at least give you an idea of what the issue is and you can work from there.
09-07-2022 09:59 AM - edited 09-07-2022 10:00 AM
It typically is more useful to describe what you want to do (graph a two-column 2D array on an xy graph), not how you want to do it.
XY graphs accepts a wide variety of datatypes, so here are a few possibilities to do the exact same thing.
(The datatype of the last version is equivalent to yours, no loop needed! Note that the index is wired to the column input)
09-07-2022 10:17 AM - edited 09-07-2022 10:25 AM
@crossrulz wrote:
The cluster size needs to be set to 2 for an XY graph.
A good rule to follow even though there is the little known oddity that a size=3 is also accepted and will graph two plots with shared X. Size can be 2 or 3, but nothing else!! (See also)
09-07-2022 10:25 AM
@altenbach - you need to post these gems somewhere central for all to benefit
09-07-2022 01:43 PM
Thanks, all. I knew it was something little like that. I did know that the for loop's output was a cluster of the wrong size, just wasn't sure which component needed to be right-clicked. I often have trouble remembering where the settings are when they're hidden in sub-menus like that. If anyone has tips for that issue, let me know.
@altenbach I appreciate your alternate XY Graph input options.
For anyone who finds this post later, here are the VIs in LabVIEW 2018, hopefully more accessible for all.
09-08-2022 09:01 AM
@sbernie2 wrote:
I did know that the for loop's output was a cluster of the wrong size,
The FOR loop is completely innocent. It's the output of array-to-cluster.
As has been said, if you hover over the wire it will tell you that the cluster size is incorrect. Curiously, It says that it expects a cluster size of three, even though it is typically two. 😄 (Yes, three works too, as mentioned)
Here are two more possibilities (but you need to be sure of the input datatype, so be careful! You'll never get an error, but you might get garbage if things don't match ... )
The bottom solution is nicer because the cluster elements are properly named. You could even give them more intuitive names, such as "current" and "voltage", or whatever the values represent.