Increasing the number of significant figures from a cursor tag
That_guy91
Hello,
I have a macro that was written by a previous lab mate that inserts a tag with the x value when you have the cursor placed on the graph. This is a very useful macro, however, on a current data set I am analyzing, I realized it only gives sigfigs to the hundreths place, but I need to look at differences in peak position that are <0.01. So I am trying to modify this macro to include more sigfigs. I do not understand however how hcsr() function abstracts the x values and the documentation does not include anything on this topic.
Any ideas would be very much appreciated.
Thanks
Macro TagItX()
variable cmPosition = hcsr(A)
variable xPosition = xcsr(A)
String LocValue = "\\Z14" + num2str(cmPosition)
Tag /O=90 /F=0 /A=MB /X=0 /Y=10/L=1 /B=1 $CsrWave(A), xPosition, LocValue
EndMacro
variable cmPosition = hcsr(A)
variable xPosition = xcsr(A)
String LocValue = "\\Z14" + num2str(cmPosition)
Tag /O=90 /F=0 /A=MB /X=0 /Y=10/L=1 /B=1 $CsrWave(A), xPosition, LocValue
EndMacro
instead of num2str, try using sprintf to insert output of hcsr() into the LocValue string in whatever format/precision you like
DisplayHelpTopic "sprintf"
September 23, 2019 at 10:32 am - Permalink
Have a look at: DisplayHelpTopic "num2str"
You probably want something like:
variable cmPosition = hcsr(A)
variable xPosition = xcsr(A)
String LocValue
sprintf LocValue "\\Z14 %.9f", cmPosition
Tag /O=90 /F=0 /A=MB /X=0 /Y=10/L=1 /B=1 $CsrWave(A), xPosition, LocValue
EndMacro
opps, too late!
September 23, 2019 at 10:40 am - Permalink
Gotta be fast to beat tony!
September 23, 2019 at 11:38 am - Permalink
I may have been a few seconds quicker to post but, as usual, it was Christian that provided helpful working code.
September 23, 2019 at 02:40 pm - Permalink
You're both incredibly helpful to your fellow Igorians.
September 23, 2019 at 02:49 pm - Permalink
@johnweeks:
you're welcome
September 23, 2019 at 03:18 pm - Permalink
well, no problem to be second after Tony.
After all it was him who introduced me to Igor, must have been in 2000 or so and IP3 ;-)
September 24, 2019 at 05:15 am - Permalink