Make Wave function trouble shooting

Hi, I am an undergrad new to Igor. Sorry for my awful programming.

I want to automate creating many histograms, but my code seems to always make the same graph.

I assume its because every iteration refers to the latest histogram iteration, but I don't know how to fix it.

My code assumes that all the waves are written in default (as in wave1, wave2, wave3, ...)


Thank you.

function MMHist(variable initialWave,variable finalWave)
    variable i
    for(i=initialWave;i<=finalwave;i++)
        wave nextWave = $"wave" + num2str(i)
        wave $nextWave_Hist
		Make/N=100/O nextWave_Hist
		Histogram/B={0,4,100} nextWave, nextWave_Hist
		wave nextnextWave = nextWave_Hist
		Display nextnextWave
	endfor
end
hegedus

Hi,

You put the results into the same destination so they in essence get over written with the latests data.

One option:

 So It creates a new wave for the histogram with a number suffix to match input and references it as nextwave_hist.  It then displays that wave.

function MMHist(variable initialWave,variable finalWave)
    variable i
    for(i=initialWave;i<=finalwave;i++)
        wave nextWave = $"wave" + num2str(i)
        Make/N=100/O $("nextWave_Hist"+ num2str(i))
        wave nextWave_Hist =$("nextWave_Hist"+ num2str(i))
        Histogram/B={0,4,100} nextWave, nextWave_Hist
        Display nextWave_Hist
    endfor
end

Andy

hegedus

Hi,

It is all part of the learning process. And we all could benefit for improving our programming skills-always.

Andy