04-01-2009 09:04 AM
Hi,
I need some help. I´m a beginner in measuerment Studio (using trial version).
I´m looking for a way to store, calculate and display datas of 2 dimensions as (Magnitude/ Frequency) or (Magnitude/Time). What is the best datatype ?
Example:
i´m reading a trace from a spectrum analyzer: I get back an Array of 500 Points (Magnitude Data)
I´m reading the start and stop frequency from the spectrum analyzer: eg start:1 GHz stop:2 GHz
1) now I want to combine the Magnitude and Frequeny datas...how can I do that ?
2) now I want to find out the maximum Magnitude and its corresponding Frequency.
3) now I want to display the spectrum in a plot
Thanks for any help....by the way: in agilent VEE I use the coord datatype, and the ramp function...I look for something similar in Measurement studio VB.net
Solved! Go to Solution.
04-06-2009 02:59 PM
Hi Josh,
Try something like this
I'm assuming that you already have the magnitude, sart and stopfrequencies from the analyzer
'set a reference to the NationalInstruments.Analysis.(pro or enterprise) library
'in the property pages of your project
'then add this line to your form
Imports NationalInstruments.Analysis.MathPublic Class Form1
'add a button and scatterplot to your form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim magnitude(500) As Double
Dim frequency(500) As Double
Dim bandwidth, startfrequency, stopfrequency As Double
Dim maxvalue As Double = 0Dim maxvaluefreq As Double = 0
Dim imaxvalue As Long = 0 Dim j As Long = 0
'get magnitude data, start and stop frequncy from signal analyzer
'with gpib or serial calls....
'for this load random dummy magnitude data
For j = 0 To 500magnitude(j) = Rnd()
Next
startfrequency = 1000000000.0
stopfrequency = 2000000000.0
'calc bandwith
bandwidth = (stopfrequency - startfrequency) / 500
'load frequency data
frequency(0) = startfrequency
For j = 1 To 500
frequency(j) = frequency(j - 1) + bandwidth
Next
'ArrayOperation functions are part of the NI Analysis Library
maxvalue = ArrayOperation.GetMax(magnitude)
imaxvalue = ArrayOperation.GetIndexOfMax(magnitude)
maxvaluefreq = frequency(imaxvalue)
Debug.WriteLine("Max Value = " & maxvalue & " at " & maxvaluefreq & " Hz")
'use scatterplot1 to display data
ScatterPlot1.PlotXY(frequency, magnitude)
End Sub
End Class
Hope this helps
Curt
04-07-2009 09:11 AM
Hi Curt,
yes...perfect ! it works !!!
🙂
Thanks for your help !!! *1beer4you*
Josh