Splitting data : Diurnal plot (as box plot)
Hello, I received a fragment of code from "hegedus" ("Mon, 08/26/2019 - 10:39 pm") to split data into several bins.
The piece of original code was to separate data over Bins from 0 to 0.1.
Original code
wave Xin,Yin
variable index
For(index=0;index<1;index+=.1)
Extract /O Yin, $("G"+num2str((index)*10)), Xin>index && Xin<(Index+0.1)
endfor
end
I would like to modify this code for a diurnal plot. My Xin wave is now a datawave containing numbers 0 through to 23 (for hours) and my Yin wave is the data that I would like to average over Xin (both waves are of the same length) .
The modified code is
wave Xin,Yin
Make/o/N=23/T GroupLabel
groupLabel = num2str(x/1)
variable index
For(index=0;index<23;index+=1)
Extract /O Yin, $("B"+num2str((index)*1)), Xin>index && Xin<(Index+1)
endfor
end
However, this code creates 23 waves B0....to B23, but is not extracting the Yin data into these waves.
I am having trouble seeing my error.
If you can help I would appreciate it.
Thanks
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Can you share the data? I would double check the Xin data and type.
Andy
August 29, 2019 at 08:14 am - Permalink
Yes of course (attached as pxp), thank you
August 29, 2019 at 09:10 am - Permalink
Hi,
Tweaked it a bit.
GroupLabel should be 24 points (0-23) and no need for the division by 1.
Second since you have the hours already defined in the Xin you can use a simple test for equality.
Third I removed the *1 in the wave name portion. I had used *10 before to create wave names but the decimal needed to be removed for the name.
wave Xin,Yin
Make/o/N=24/T GroupLabel
groupLabel = num2str(x)
variable index
For(index=0;index<24;index+=1)
Extract /O Yin, $("B"+num2str(index)), Xin==index
endfor
end
The box plot is shown as created by IP8.
Andy
August 29, 2019 at 09:28 am - Permalink
Hello again Andy,
Thank you very much. This worked nicely, and I managed to make the box plot with the data points included using IP6!! It just took a bit more time :)
August 30, 2019 at 09:43 am - Permalink