How to extract data from a text file and use logical if-else statement after some calculations and creating a new column in the data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
RAJ
le 7 Mar 2019
Réponse apportée : Adarsh Ghimire
le 7 Mar 2019
I have a text file stress_data.txt attached herewith in which I have 5 columns. Out of these 5 columns I need to find 1/3*(Col 3 + Col 4 +Col 5) = Col 6, which is a new column.
Now I need to put logical if-else statements for the variable in Col 6 to analyse and interpret a phenomena.
I dont know :
1) how to execute the calculation "1/3*(Col 3 + Col 4 +Col 5) = Col 6"
2) extract the values of Col 6
3) execute if-else statement to the variable in Col 6.
I have tried this but it is not working :
load stress_data.txt
stress_data = readtable('stress_data.txt')
stress_data.HP = stress_data{:,3:end}/3
Please help.
N.B I just need the step by step syntax as of how to execute the whole thing mentioned above.
0 commentaires
Réponse acceptée
Adarsh Ghimire
le 7 Mar 2019
data = load ('stress_data.txt');
col6 = (1/3).*(data(:,3)+data(:,4)+data(:,5));
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Other Formats dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!