Creating if, else statement for Excel columns
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to interpret force data from an Excel file and trying to use an if else statement for which columns to use, then finding the max force of each column being used. There's 20 columns that I'm looking at and I need data from only 5 of them. A column will be used if the minimum is 500 N or greater. I cannot use use a column if it doesn't meet that minimum requirement.
Currently I have this, but am not sure how to finish executing it:
FP1 = xlsread('P19_SHOES.xlsx','B5:K105');
if min(FP1,[],1)>=500
FP1_Max = max(FP1,[],1)
else
FP1_Max = 0
end
Currently when I run the code, I'm getting FP1_Max = 0 as the output.
0 comentarios
Respuestas (1)
Siddharth Bhutiya
el 17 de En. de 2019
min(FP1,[],1)>=500
In your code snippet the above line would give you a logical array indicating if a column meets your requirement of having a minimum value of 500. Once you have this you can index into the original matrix to obtain a new matrix that contains only those rows as follows
desrired_columns = min(FP1,[],1)>=500;
FP1_new = FP1(:, desired_columns);
The new matrix with the desired columns can be used for further analysis. For example, to get the max values you can do something like this
FP1_max = max(FP1_new,[],1);
0 comentarios
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!