Matching dates in two different tables and inserting value in separate column in second table when dates match.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Wendy Cameron
il 10 Mag 2018
Commentato: Wendy Cameron
il 12 Mag 2018
I want to match a date from one table column, with a date from a second table, and when the dates match, insert a value in a separate column in the second table, corresponding to that date. For example the first table is a list of flowering dates each year and the second table is the daily weather data for those years i.e. the tables are different sizes. If the date in the first table matches the date in the weather data, I want to insert "flowering" in a separate column corresponding to that date in the second table. This is so so I can then do for example temperature summations leading up to flowering.
0 Commenti
Risposta accettata
Guillaume
il 10 Mag 2018
That sounds very straightforward as long as you want an exact match for the date down to the second (I'm assuming your dates are stored as datetime
ismatch = ismember(yourfirsttable.datecolumn, yoursecondtable.datecolumn);
yoursecondtable.newcolumn = categorical(ismatch, [false true], {'not flowering', 'flowering'});
would be an option. Another option would be to label the new column flowering and just have true/false as values of the column:
yoursecondtable.flowering = ismatch;
3 Commenti
Guillaume
il 11 Mag 2018
I'm sure it can be done and probably fairly easily, however I don't completely understand what you want. An example with some data would make it much clearer.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Calendar in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!