02-23-2012 08:47 AM
hi,
I have understood preferable choice is to initialise array first and replace elements in an array instead of inserting new element in an array e.g. in a while loop.
So I started to this evaluate since I have an application where I want to read lots of measurements from a txt file and display them in a XY graph. XY graph must show Y value and corresponding X value either red if it is out of range and in green if it is in range. I found a solution to do it with an array of clusters.
In attached example I have two different methdologies represented. My problem is that upper solution doesn't display content of all measurements. Can somebody tell me what I'm doing wrong ?
regards,
petri
Solved! Go to Solution.
02-23-2012 09:02 AM
I changed your top VI so that it works. Please take a look and see what I did. It is also much faster.
02-23-2012 09:05 AM
02-23-2012 09:13 AM
thanks for your fast response!
I see the point. Somehow I interpreted from LV help that the XY graph would take an array of clusters as input which I thought further is plotted completely - with other words - when my original while loop has finished replacing the elements.
regards,
petri
02-23-2012 09:15 AM - edited 02-23-2012 09:17 AM
Never mind
02-23-2012 09:20 AM
Why are you using three number for your XY graph? I would expect that you would have one X and one Y.
02-23-2012 09:24 AM - edited 02-23-2012 09:29 AM
@aeastet wrote:
It is also much faster.
That benchmark is completely meaningless, because both code parts execute in parallel. the result will highly depends on the number of CPU cores.
Also, since you have a fixed number of iterations, a FOR loop would be the correct structure. It will allow further optimization.
I am also not sure why you give a cluster of three elements (instead of two) to an xy graph. That's not an officially supported data structure and makes very little sense. What's the third point supposed to represent?
Do you need to intereactively see the graph as it builds or is it sufficient to see the final result?
02-23-2012 09:30 AM
@altenbach wrote:
@aeastet wrote:
It is also much faster.
That benchmark is completely meaningless, because both code parts execute in parallel. the result will highly depends on the number of CPU cores.
Also, since you have a fixed number of iterations, a FOR loop would be the correct structure. It will allow further optimization.
I am also not sure why you give a cluster of three elements (instead of two) to an xy graph. That's not an officially supported data structure and makes very little sense. What's the third point supposed to represent?
Do you need to intereactively see the graph as it builds or is it sufficient to see the final result?
If he reads a file he would know the size of the array that he is working with. So the for loop would be more flexible if this were not the case. Since we know how big the array is then we could read it in and I am not sure why we would need to do any of this unless we are replacing old data or reading from a file is is always changing.
02-23-2012 09:56 AM
in a field measurement application XY presents geographical coordinates on the earth. A measured value from the measurement equipment in that coordinate position is stored in a log file inclusive the XY position. all this is done parallel max for 7 separate measurements. so first after reading the log file I know the number of parallel measurements and the number a number of XY positions.
in my off-line application I want to display this log file. There is no need to display interactively all these XY points but of course it is funny to see it interactively. in a certain XY point the measured value is compared to a limit. if it is below the limit, a red dot is displayed, if it is above the limit, a green dot is displayed. using cluster with three elements was a method I found to put red and green dots in one XY graph, eg. Y=coordinateY, X(green)=NaN,X(red)=coordinateX. Perhaps there is a better way to display the data, but I couldn't find it.
regards,
petri
02-23-2012 11:27 AM - edited 02-23-2012 11:27 AM
@Petri wrote:
... using cluster with three elements was a method I found to put red and green dots in one XY graph, eg. Y=coordinateY, X(green)=NaN,X(red)=coordinateX. Perhaps there is a better way to display the data, but I couldn't find it.
That is an odd thing and makes little sense. Why three? four, five, etc are NOT supported, so what if you want more than one color? (in range, fail high, fail low?). For more detail see the discussion here.
In any case, reading all these values from a datafile and creating xy plots is trivial. I would recommend to use complex data. a single complex array will graph IM vs RE. For multiple plots, combine them using "build cluster array". No loops needed. 😉
Here's a quick draft. Of course you need to decide if the data is in columns or rows, etc. so modify as needed.