03-24-2010 12:53 PM
Hi, I have a question about manipulating an XY Graph.
1) Everytime the plot crosses the x-axis for y-value going upwards, I want the plot to change color, until it crosses the 0 again going upwards, and I want that specific portion to have a different color. It is really hard to explain this so I'm going to post a picture:
[URL=http://img691.imageshack.us/i/xygraphexample.jpg/][IMG]http://img691.imageshack.us/img691/4540/xygraphexample.jpg[/IMG][/URL]
As you can see, if the graph crosses the x-axis while decreasing, it shouldn't change colour. Only increasing.
I cannot figure out how to do this. I know it will require multiple plots, but how would I randomly change the color as well as detect if its crossing it going upwards or not.
Any help would be appreciated.
Thanks
Solved! Go to Solution.
03-24-2010 01:27 PM
Hi Bilal,
you can attach pictures here in the forum directly, even embed them in the text. No need for 3rd party servers as they might even be blocked for other users...
How to check for positive crossing x axis?
Simply check for "x(t-1)<0 AND x(t)>=0" to detect such an event.
How to add plots?
You need an array of plots. So you have to split your data into several subarrays, arrange the subarrays to plots, then build an array of plots. It's much easier when you first collect all data, then search the interesting crossing points to analyze the data
03-24-2010 03:18 PM
You can use the trigger and gate express VI to quickly find all rising zero crossings.
Initialize an array of NaN that is the same size as your original data.
Then drop in the triggered sections
here is a quick example I cobbled together - you should get the basic idea
03-25-2010 08:53 AM
Hi.
Do you think you could post that VI file.
Also, what if my x-axis is not at 0, and is user configurable?
03-25-2010 10:08 AM
sorry - I didn't save the VI that I made - you should be able to duplicate what's shown in the jpg.
For the false case, when no more triggers are detected, just take the remaining portion of the original array.
And yes, the trigger level can be user configurable - just make a control and pass it into the trigger and gate function for the "Threshold"
03-25-2010 10:16 AM
Hey, thanks it works now.
One problem is that there is a gap between the first triggered set of data and the second. It gets cut off at the x-axis, and the next point is like 0.12 or something, so it starts off a bit above the axis so there is empty space between the two triggered plots.
Is there any way of avoiding that?
03-25-2010 10:22 AM
Also, I can't seem to find a "Threshold" terminal. All I see is an option for having a manual trigger, but nowhere to configure it.
I never use express VIs so sorry if the question sounds dumb.
03-25-2010 11:34 AM
OK - lucky I'm not too busy today ....
I usually don't use express VIs either, but was just looking for a quick solution for you.
here is the sample done with just the basic trigger function - no express VI.
Also added a user selectable threshold.
Next, regarding the space between plots, if there is no data in the original, there will be no data in the colors either.
see second attachment
03-25-2010 11:37 AM
sorry the jpg had only the false case shown - here is an image of the true case also
03-25-2010 01:16 PM