Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by