필터 지우기
필터 지우기

How to merge data in excel files?

조회 수: 3 (최근 30일)
shazwani amran
shazwani amran 2013년 4월 9일
below is sample data from an excel file that I need to merge.
1 1 1 2 3 3 4 4 4
1.2 4.4 7.1
2.5 5.2 5.5
3.9 6.5 4.3
the above data need to be merge according to the first row which have same value to become like this:
1 2 3 4
1.2 4.4 7.1
2.5 5.2 5.5
3.9 6.5 4.3
I'm really appreciate someone that can help me.thank you.

답변 (1개)

Iman Ansari
Iman Ansari 2013년 4월 9일
편집: Iman Ansari 2013년 4월 9일
Hi
Data=xlsread('name.xlsx');
Data(isnan(Data))=0;
for i=1:4
Output(:,i)=[i; sum(Data([false true true true],Data(1,:)==i),2)];
end
  댓글 수: 2
shazwani amran
shazwani amran 2013년 4월 21일
Hi, how if the data was like below. is it possible for me to merge them?
5 5 5 8 7 7 9 9 9 .....(and so on)
1.2 4.4 7.1
2.5 5.2 5.5
3.9 6.5 4.3
after importing the excel file that contained data like above, the data need to be merge according to the first row which have same value to become like this:
5 8 7 9
1.2 4.4 7.1
2.5 5.2 5.5
3.9 6.5 4.3
Iman Ansari
Iman Ansari 2013년 4월 21일
clear
Data=xlsread('name.xlsx');
Data(isnan(Data))=0;
n=nnz(diff(Data(1,:),1,2))+1;
Idx=[1 find(diff(Data(1,:),1,2))+1];
for i=1:n
Output(:,i)=[Data(1,Idx(i)); sum(Data(2:4,Data(1,:)==Data(1,Idx(i))),2)];
end

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by