필터 지우기
필터 지우기

Need to turn table within cell to array

조회 수: 1 (최근 30일)
David Chan
David Chan 2023년 2월 3일
댓글: David Chan 2023년 2월 7일
So I have a table within a table and would like to turn it into a column vecotor (displaying all individual data), I tried a couple of differetn function but that did not work

답변 (1개)

Tushar Behera
Tushar Behera 2023년 2월 3일
Hi David,
I believe you have a table which consists of several other tables. You want to convert one of those table into a vector array.
You can use "table2array" function in ordert o acheive the above functionality. For example:
% Define the table within a table
tableInTable = table({table(1:3, 'VariableNames', {'a'}); table(4:6, 'VariableNames', {'b'})},...
'VariableNames', {'NestedTable'});
% Convert the table within a table to a column vector
columnVector = table2array(tableInTable.NestedTable{1})
Hope this answers your query.
Regards,
Tushar
  댓글 수: 1
David Chan
David Chan 2023년 2월 7일
columnVector = table2array(BCG_data_table_converted(1,1));
columnVector = cell2mat(columnVector);
I tried the above, the first line work, reurning a 1x1 cell, however, the second line does not work

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by