NI Home > Community > NI Discussion Forums

LabVIEW

Reply
Member
Mark_Wang
Posts: 16
0 Kudos

Convert 1D string Array to Numeric Array

I read a number of strings from GPIB card.They were divided by comma.What i do is saving them in numeric form and plot in waveform Control.Can somebody give some advice?
Active Participant
Nadav Chernin
Posts: 473
0 Kudos

Re: Convert 1D string Array to Numeric Array

What type of data you get from GPIB: 1d string array or 1 string, that consist many numbers. From your question i understand this is last case.
Look attached example.
Active Participant JRA
Active Participant
JRA
Posts: 781
0 Kudos

Re: Convert 1D string Array to Numeric Array

I am attaching a vi called Extract Numbers.vi. You input a string of numbers, separated by commas, and it outputs an array of the numbers. You may want to take a look at this. You can find this on National Instruments' website in their example program database. This should be what you're looking for.
J.R. Allen
Member
sash
Posts: 21
0 Kudos

Re: Convert 1D string Array to Numeric Array

Mark_Wang wrote in message news:<5065000000080000009C4F0000-1023576873000@exchange.ni.com>...
> I read a number of strings from GPIB card.They were divided by
> comma.What i do is saving them in numeric form and plot in waveform
> Control.Can somebody give some advice?

Hi Mark,
if I've understood you correctly, you have say 5 elements in 1D
arrays of strings. Each element is related to a particular plot, so
each element is a comma deliminated string. You want to split this
into 5 1D numeric arrays, i.e. interpret each array element into a 1D
array, and pass this as an individual plot to a Waveform graph.

If this is so, try the following :
Place a for loop on the diagram. Wire the 1D array of strings to the
edge of the loop. Inside the loop place the Spre
adsheet sting to
array.vi (found under the string functions). To this, wire the 1D
array, with indexing ON to the spreadsheet string input. To the format
string input, wire a string constant of "%f" (without the quotes). To
the deliminator, wire a string constant of "," (without the quotes),
and to the Array type input, wire a 1D array of double precision
numerics (easiest way is to use the wiring tool, right click on the
input and create constant. Then select the constant, and remove a
dimension.
Wire the output of the Spreadsheet string to array.vi to the for loop
edge, and (with indexing ON on this point too) wire this output
directly to the waveform graph.
If that's a bit confusing, e-mail me direct, and I have the .vi I've
proved it on.

Hope that helps

Sash.
Member
labviewhokie
Posts: 13
0 Kudos

Re: Convert 1D string Array to Numeric Array

This thread was started so long ago I hope I get a reply.
 
So first off Sash, those were excellent directions. I however get stuck at the last step, I don't know which graph VI to send the output to in order to get a XY graph (see attachment for how far I got...).
I am using LabView 7. 1
All I have is 2 inputs:
X axis will be channel numbers (coming from my mux module)--I get this in string format
Y axis will be a bunch of voltage readings (from my DMM)
 
Please let me know what the last step is so I can complete my waveform. Thanks!!!
 
Knight of NI
Dennis_Knutson
Posts: 33,179
0 Kudos

Re: Convert 1D string Array to Numeric Array

[ Edited ]

Show below is the basics for what you would do. Since all that you have provided is a image of a small piece of code, I have no idea how the data is your 2D array is arranged. The example below gets column 0 for the x array and column 1 for the y array. You may need to switch these around or to use the rows instead.



Message Edited by Dennis Knutson on 02-12-2008 07:40 AM
Member
CU Boulder
Posts: 1
0 Kudos

Re: Convert 1D string Array to Numeric Array

Your VI is now obsolete and cannot be used...
Knight of NI
RavensFan
Posts: 15,609

Re: Convert 1D string Array to Numeric Array


CU Boulder wrote:
Your VI is now obsolete and cannot be used...

Who is your comment directed towards?  And why in a 9-year old thread that hasn't been replied to in the last 3-1/2 years?