Creating a new column in a table using if condition and equation
Afficher commentaires plus anciens
Hi I have a table with daily data for a year: 365 rows x 4 columns. I need to create a new column which is defined by a function that I will show below and takes the data from other columns in the table.
For example lets say the columns of the table are labelled: A,B,C,D and the new column would be E
If D<1.2 then E=1
If D>6.5 then E=0.23
anything else E=1.18exp(-0.18*D)
This is what I have so far but the new column is only doing the last calculation and isnt following my limit values.
T = readtable('Data.csv');
if T.D <1.2
T.E = 1.0;
elseif T.D >6.5
T.E = 0.23;
else T.E = 1.18*exp(-0.18*T.D);
end
disp(T)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Language Support dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!