Dimension item label error while attempting to populate output variables wave

Posts: 7
Joined: 2017-05-23
Location: United States

I am trying to follow "Wave Assignment and Indexing Using Labels" example in the help file, with a slight modification: I am using WaveStats to generate my output variables instead of FindPeak, intended to populate a wave with 10 rows and 4 columns After setting dimension labels for the desired WaveStats output variables, the next 4 lines of code, which would place the extrema values and their row locations into the appropriate cells of the output wave, generate the error "Couldn't find the given dimension item label." I'm sure I'm missing something, ignorant of an indexing rule or something, but I can't see it. Hopefully the code posts correctly, this is my first time sharing any code on the forum.

Make test=sin(x/30)WaveStats test
  V_npnts= 128; V_numNaNs= 0; V_numINFs= 0; V_avg= 0.33891; 
  V_Sum= 43.3805; V_sdev= 0.582272; V_sem= 0.0514661; 
  V_rms= 0.671753; V_adev= 0.492791; V_skew= -0.643665; 
  V_kurt= -0.851805; V_minloc= 127; V_maxloc= 47; 
  V_min= -0.887431; V_max= 0.999991; V_minRowLoc= 127; 
  V_maxRowLoc= 47; V_startRow= 0; V_endRow= 127; 
•Make/N=(10,4) metrics
•SetDimLabel 1,0,Vmin,metrics
•SetDimLabel 1,1,Vmax,metrics
•SetDimLabel 1,2,VminLoc,metrics
•SetDimLabel 1,3,VmaxLoc,metrics

Posts: 1948
Joined: 2007-06-29
Location: United States

What you have posted so far looks good. And when I execute your commands above, this assignment works correctly:
metrics[0][%Vmin] = V_min
Could you post the command that failed?

John Weeks
WaveMetrics, Inc.

Posts: 7
Joined: 2017-05-23
Location: United States

The command that failed is:


As I suspected, it was a syntax error on my part. Your amended code contains a [0], and I guess I need to brush up more on that section of the help file. What does the [0] designate? I noticed the label assignment example doesn't include that character (code reposted below). Thank you very much for the help!
// Make a wave and get peak parameters
Make test=sin(x/30)
FindPeak/Q test
// Create a wave with appropriate row labels
Make/N=6 PeakResult
SetDimLabel 0,0,'Peak Found', PeakResult
SetDimLabel 0,1,PeakLoc, PeakResult
SetDimLabel 0,2,PeakVal, PeakResult
SetDimLabel 0,3,LeadingEdgePos, PeakResult
SetDimLabel 0,4,TrailingEdgePos, PeakResult
SetDimLabel 0,5,'Peak Width', PeakResult
// Fill PeakResult wave with FindPeak output variables
PeakResult[%'Peak Found']   =V_flag
PeakResult[%PeakLoc]        =V_PeakLoc
PeakResult[%PeakVal]        =V_PeakVal
PeakResult[%LeadingEdgePos] =V_LeadingEdgeLoc
PeakResult[%'Peak Width']   =V_PeakWidth
// Display the PeakResult values and labels in a table
Edit PeakResult.ld

Posts: 1675
Joined: 2007-06-21
Location: United States

The example uses a 1D wave so one index is needed to specify the row.

Your case uses a 2D wave so two indices are needed, one for the row and one for the column.

"[0]" in John's example means "row 0".

Posts: 7
Joined: 2017-05-23
Location: United States

Rookie mistake! Thanks again to both of you for the help. I am trying to come up with a routine to loop through a very large set of sinusoidal data, which indexes the minima and puts those x value locations into a table to give something like "Cycle# StartRow StopRow." Then I will use those values as range inputs for plotting and further analysis on my 4 synchronized data waves. I'm sure I will be back on the forum soon.


Back to top