Creating if, else statement for Excel columns
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Siddharth Bhutiya
2019 年 1 月 17 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!