Effacer les filtres
Effacer les filtres

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)
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.

Réponse acceptée

Adarsh Ghimire
Adarsh Ghimire le 7 Mar 2019
data = load ('stress_data.txt');
col6 = (1/3).*(data(:,3)+data(:,4)+data(:,5));

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps 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!

Translated by