How to create waves with sequential name in a loop and use them as a variable in another loop?
Kzai
I want to make waves with names like wave1,wave2...........wave50 in a loop.
For this I wrote
Function data()
string name ="wave"
string U
variable i
for(i=1;i<30;i+=1)
sprintf U, "%s%d", name, i //Here It makes wave 1 wave2..etc
//print U //upto this it is working fine and printing wave 1 wave2.............wave30
make/N= (100) U //this i wrote to make waves with the names stored in U, but its showing error
endfor
end
Can you please suggest me How to write this properly and then further use them in a loop as a variable.
Problem2.
suppose after making this (size=100*1) N no of waves I want to concatenate each of them with my y and z waves to make a triple wave in a loop.Is there any way to do it in a loop or I have to write N separate concatenate command?
Wave xWave, yWave, zWave
String xyzWaveName
Concatenate/O {xWave, yWave, zWave}, $xyzWaveName
Wave xyzWave = $xyzWaveName
return xyzWave
End
Function Demo()
String baseName ="wave"
Variable i
for(i=0; i<3; i+=1)
String xName
sprintf xName, "%sX%d", baseName, i
Make/N= (100) $xName
Wave xWave = $xName
String yName
sprintf yName, "%sY%d", baseName, i
Make/N= (100) $yName
Wave yWave = $yName
String zName
sprintf zName, "%sZ%d", baseName, i
Make/N= (100) $zName
Wave zWave = $zName
String xyzWaveName
sprintf xyzWaveName, "xyzWave%d", i
Wave xyzWave = MakeXYZWave(xWave, yWave, zWave, xyzWaveName)
Printf "Created %s\r", NameOfWave(xyzWave) // Will be same as xyzWaveName
KillWaves xWave, yWave, zWave
endfor
End
Execute these commands to read about the underlying concepts:
DisplayHelpTopic "Wave References"
October 26, 2013 at 09:09 am - Permalink
October 26, 2013 at 11:12 pm - Permalink