concatenating wavelist items

I am having some trouble with the code that I wrote in which I'd like to concatenate waves that are from a wavelist into a new destination wave. Maybe it's something about the syntax that I am missing? Some of these waves have NaN values which I'd like to preserve in the final concatenated waves.

function cyclelist()


string string_list = wavelist("waves_final_*",";","")
wave dest_list

variable i

variable endnum = itemsinlist(string_list)
    for(i=0;i<=endnum;i+=1)
        string ywavename = stringfromlist(i,string_list)
        concatenate /NP/O {$ywavename},dest_list
    endfor 

end
Hi,

The NaNs are not the problem. Your problem is the overwrite flag in Concatenate. The code repeatedly concatenates just one wave into the destination and overwrites it. Actually, if you check the help for Concatenate, you can supply a semi-colon separated string list in a one-liner to do what you are trying to do.

Concatenate [type flags][flags] waveListStr, destWave
Actually another problem is the way that your loop is written. The limit is should be i = endnum. As written the loop won't execute the first time since 0 is <= endnum.