I have a data set like this, How can i delete raw ofs values less than 10, and T values which are zero, How can i sum s values which are related to same T values ?

조회 수: 2 (최근 30일)
S T
878.00 9.00
1.00 12.00
166.00 12.00
143.00 12.00
160.00 12.00
173.00 12.00
144.00 12.00
3229.00 0
150.00 12.00
144.00 12.00
122.00 13.00
132.00 13.00
2.00 13.00
138.00 13.00
139.00 14.00
133.00 14.00
4.00 14.00
137.00 14.00
2473.00 0
118.00 14.00
127.00 14.00

채택된 답변

C.J. Harris
C.J. Harris 2016년 1월 21일
One way to do it:
data = [878.00 9.00
1.00 12.00
166.00 12.00
143.00 12.00
160.00 12.00
173.00 12.00
144.00 12.00
3229.00 0
150.00 12.00
144.00 12.00
122.00 13.00
132.00 13.00
2.00 13.00
138.00 13.00
139.00 14.00
133.00 14.00
4.00 14.00
137.00 14.00
2473.00 0
118.00 14.00
127.00 14.00];
% Remove S values less than 10
data = data(data(:,1)>=10,:);
% Remove T values that are zero
data = data(data(:,2)~=0,:);
% Sum equal elements of T
elems = unique(data(:,2));
elemSums = arrayfun(@(x)(sum(data(data(:,2)==x))), elems);
% Display results
fprintf('T value: %.2f | Sum: %.2f\n', [elems elemSums].')
Result:
T value: 9.00 | Sum: 878.00
T value: 12.00 | Sum: 1080.00
T value: 13.00 | Sum: 392.00
T value: 14.00 | Sum: 654.00
  댓글 수: 2
Lakshmi Navya Sunkara
Lakshmi Navya Sunkara 2016년 2월 23일
Hello, I tried this in different way and would like to share it
k = find(S(S<10));
P = find(T(T==0));
S(k;:)=[];
T(k;:)=[];
sum = sum(S(S==T))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by