Matrix Manipulation of a specific column

조회 수: 8 (최근 30일)
Brady Wayne Robinson
Brady Wayne Robinson 2018년 9월 27일
댓글: Hyeokjin Jho 2018년 10월 1일
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!

답변 (1개)

Hyeokjin Jho
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
Brady Wayne Robinson
Brady Wayne Robinson 2018년 9월 27일
This doesn't seem to work. The error I get is Undefined function 'gt' for input arguments of type 'table'.
Error in Matlab_Homework1 (line 16) selectedNumbers{i} = pickedColumn(pickedColumn>threshold);
>>
Hyeokjin Jho
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 CenterFile Exchange에서 Timetables에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by