How to create new wave from existing wave
cmm557
Column 1 column 2 column 3 column 4 column 5
03/08/2017 cf0000 0.45 0.300 0.298
04/08/2017 cf0200 0.4 0.6 0.3
05/08/2017 cf0000 0.5 0.2 0.1
in the example above, I only want to extract the values from the row that has the status cf0200 and put it in a new table (all values from column, 1, 2, 3, 4, and 5 will be transferred to the new table if column 2 has cf0200). How would I program this? I am new to igor and am having a lot of trouble trying to figure out the code for this. Any help would be appreciated!
extract column2, c2, StringMatch(column1, "cf0200")
extract column3, c3, StringMatch(column1, "cf0200")
extract column4, c4, StringMatch(column1, "cf0200")
extract column5, c5, StringMatch(column1, "cf0200")
edit c1, c2, c3, c4, c5
Use a for loop in a procedure file
variable i
wave /T column2
for (i=1;i<6;i+=1)
extract $("column"+num2str(i)), $("c"+num2str(i)), StringMatch(column1, "cf0200")
endfor
edit c1, c2, c3, c4, c5
end
I assume column2 is text based and not hex formatted numbers. Otherwise, replace
StringMatch(column1, "cf0200")
bycolumn2==0xcf0200)
andwave /T column2
bywave column2
.In case you want to overwrite the source waves, use 'columnX' instead of 'cX' together with the /O flag for extract AND make sure your 'marker column' (column2) is processed last. Here, the existing table will update automatically and you won't need that edit command at the end of each code.
HJ
October 10, 2017 at 02:24 am - Permalink
The date I would convert to Julian:
datetojulian(2017,08,03)
(displayhelptopic "dateToJulian"
)The status code I would convert appropriately (idk how many status codes you have, is RAM an issue, etc.).
Then use something like that:
wave w_in
variable i
variable v_nrows = dimsize(w_in, 0)
string s_row
for (i=0; i<v_nrows; i+=1)
sprintf s_row, "w_row%d", i
matrixop/o $s_row = row(w_in,i)^t
endfor
for (i=0; i<v_nrows; i+=1)
//s_row = "w_row1"
sprintf s_row, "w_row%d", i
wave w_row = $s_row
print w_row
endfor
end
best,
_sk
October 10, 2017 at 05:06 am - Permalink
An Igor date/time value is numeric - seconds since 1904-01-01:
DisplayHelpTopic "Date/Time Waves"
I don't think it is a good idea to convert to Julian because some Igor operations expect Igor date/time format. For example, it must be Igor date/time format to use as the X axis in a graph.
October 10, 2017 at 01:31 pm - Permalink
Good to know.
best,
_sk
October 11, 2017 at 12:47 am - Permalink
October 16, 2017 at 12:58 pm - Permalink