COMBINING MULTIPLE TABLES TOGETHER

I am working with a .mat file that has 100 tables (with different names) attached to it. I want to combine all those tables into a new single table without using individual names. Please help

댓글 수: 4

KSSV
KSSV 2018년 10월 9일
The widths of each table are same?
Guillaume
Guillaume 2018년 10월 9일
It would be simpler if the mat file was attached to the question
RUSSELL KHAJURIA
RUSSELL KHAJURIA 2018년 10월 11일
yes widths are the same and I wont attach the .mat file. I have used the eval function to do the job but I want to do it without eval function??
KSSV
KSSV 2018년 10월 11일
I wont attach the .mat file why you don't attach a file, when you are asking a question in the forum?

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

답변 (2개)

KSSV
KSSV 2018년 10월 11일

0 개 추천

Type = {'Autostable' ; 'Auto' } ;
Status = { 'Success' ; 'Failure'} ;
Rank = [23 56 ]' ;
T1 = table(Type,Status,Rank) ;
Type = {'Manual' ; 'Manual' ; 'Manual' ; 'Reinitiate' } ;
Status = {'Failure' ; 'Disconnect' ;'Success' ; 'Success'} ;
Rank = [12 45 45 42]' ;
T2 = table(Type,Status,Rank) ;
T = [T1 ; T2]
% Use cat
T = cat(1,T1,T2)
Stephen23
Stephen23 2018년 10월 11일
편집: Stephen23 2018년 10월 11일

0 개 추천

"I have used the eval function to do the job but I want to do it without eval function??"
That is a good idea, because eval makes code slow, complex, and buggy. Read this to know why:
First import the .mat file into a structure:
S = load(...);
Then you have a choice: either loop over its fieldnames and use dynamic fiekdname to access each table:
N = fieldnames(S);
N = natsort(N); % download from FEX
C = cell(size(N));
for k = 1:numel(N)
C{k} = S.(N{k});
end
T = vertcat(C{:}); % or whatever way you want to join the tables.
or use struct2cell and a simple concatenation:
C = struct2cell(S);
T = vertcat(C{:});
If you want to use innerjoin (or similar) on multiple tables then you will need to use a loop.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2018년 10월 9일

편집:

2018년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by