create a variable and specify its column
Mostra commenti meno recenti
Suppose I have a table
day temperature
1/1/2020 30
I want to create a vaiable 'month" from 'day' and put it next to 'day' like
day month temperature
1/1/2020 1 30
Please advise.
2 Commenti
the cyclist
il 28 Giu 2020
For you future reference, it is better to actually show what you have via MATLAB syntax (or actually uploading the data). Otherwise, we need to guess about the formats of everything.
Specifically, is day a string, a character array, or a datetime?
alpedhuez
il 29 Giu 2020
Risposta accettata
Più risposte (1)
Gaganjyoti Baishya
il 28 Giu 2020
Hi
You can get the month from the day string by iterating it till you get the month.
for i=1:size
if day(i)=='/'
if day(i+2)=='/'
month=day(i+1);
else
month=day(i+1) + day(i+2) %char concatenate
end
break;
end
month gives the required value of month. You just need to put it in the column.
1 Commento
alpedhuez
il 29 Giu 2020
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!