How to get values from multiple columns based on the values of one column ?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have an 85x3 double dataset made up of months, years and timestamps. i want to extract the values from all 3 columns based on month e.g december/12 then create a new variable with just the selected data in the columns that correspond with 12 for years 2007-2014
1 Kommentar
Adam Danz
am 19 Aug. 2021
Since you described the data as double precision, your timestamps must be numeric instead of datetime. Any reason for that? Datatime values are usually more easy to work with. How are you timestamps represented as numeric values?
Antworten (1)
Adam Danz
am 19 Aug. 2021
Bearbeitet: Adam Danz
am 27 Aug. 2021
This is how I imagine your data are organized based on your description.
% [year, month, data, ...]
data = [repelem((2007:2014)',12,1), repmat((1:12)',8,1), rand(96,5)]
Get all values from column 3 and month 12 with months in column 2 of the data.
% v-months v-column 3
vals = data(data(:,2)==12, 3)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!