Matrix Manipulation of a specific column
11 ビュー (過去 30 日間)
古いコメントを表示
I have data in excel that is 17 columns by 4800 rows. The 17 columns represent different muscles, and the rows represent times they are "activated." For each column I need to know which numbers in that column are greater then 10 and what that number is. Once I find all those different numbers I need to sum them up. Just uncertain how to do this. Thank You!
0 件のコメント
回答 (1 件)
Hyeokjin Jho
2018 年 9 月 27 日
Assuming Data is the matrix that containing your data,
threshold = 10;
for i = size(Data,2)
pickedColumn = Data(:,i);
selectedNumbers{i} = pickedColumn(pickedColumn>threshold);
summedNumbers(i) = sum(selectedNumbers{i});
end
will work.
Numbers greater than 10 of column i is stored in selectedNumbers{i}, and summed value in summedNumbers(i)
2 件のコメント
Hyeokjin Jho
2018 年 10 月 1 日
Apparently Data seems to be a table instead of normal matrix.
threshold = 10; for i = size(Data,2) pickedColumn = Data{:,i}; selectedNumbers{i} = pickedColumn(pickedColumn>threshold); summedNumbers(i) = sum(selectedNumbers{i}); end
To extract data from table, you have to change Data(:,i) to Data{:,i}.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!