03-01-2011 01:41 PM
Hello
I don't know if this is the right title. I have a vi that creates a 2D array with 100 elements by 100 hundred elements. I was wanting this to be the Z axis. Then for each element i was wanting it to have an X-value and Y-value.
Any ideas on how to do this would be appreciated.
Thanks, Craig
03-01-2011 01:53 PM
Sounds like what you want is a two dimensional array of a two item cluster, where the cluster is made up of an "X -value" item and a "Y-value" item. Is that what you want a 100X100 array of paired values?
03-01-2011 01:56 PM
You can also use a 100x100 array of complex numbers.
Define the real part as x and the imaginary part as y. Keeps the data structures simple. 😄
03-01-2011 04:40 PM
If i use a complex array would it not just give one output. I intend to output each array to a oscilloscope. So when i index an X-array and a Y-array it will give positions on the oscilloscope. Then for each position produced on the oscilloscope it would turn the pointer on or off depending on the third array produced by my VI. For my VI i produced I would like to have the elements have a location provided by an X-array and Y-array.
Any Ideas
Craig
03-01-2011 04:54 PM
Well, you should probably have used an entire paragraph in the initial problem description. 😄 It is still not entirely clear.
Originally, you said the 2D array has 100x100 (=10000) elements. Now you have an x array and a y array...
XY graphs accept compex 1D arrays directly and will graph RE vs. IM.
In order to turn off a point, use a third array of the same lenght and make the element either 0 or NaN. Add it to your complex array before graphing, taking advantage of the fact that elements containing NaN don't show.
It would be so much easier if you could attach a small VI containing typical arrays as default values so we get a better idea on what you actually have.
03-01-2011 05:16 PM
The Vi below imports an image, thresholds it and output to an array of ones and zeros. These ones and zeros will turn the dot on the osciloscope on and off. I need two other arrays that will give them a position on the osciloscope i.e the X-array and the Y-array. So i was wondering if i could give each element a positon rather have three rather large arrays. The reason why i am not wanting to use a complex array is because the osciloscope has two seperate inputs for X and Y. So therefore i need to produce 2 seperate voltages which i have found to be easier without using complex arrays.
Thanks
Craig
P.S this VI dosen't scale the image to 100x100 array. So a larger resolution picture would be more difficult to work with. I have another working VI that scales the image but it isn't at this computer.
03-01-2011 05:34 PM - edited 03-01-2011 05:35 PM
Sorry, I don't have IMAQ.
Do you need to scall the full 2D array on the scope or is it sufficient to only send the ON positions? What percentage of elements are typically ON?
If you want to send the entire grid:
Build 3 arrays in the inner loop, reshape them to a 1D array and send to the scope, e.g. as follows.
(Isn't there a function to turn an entire image into a numeric array directly? Might be more efficient than tube-feeding one pixels at a time....)