필터 지우기
필터 지우기

How to create a double array from a cell array

조회 수: 16 (최근 30일)
Asim Shahzad
Asim Shahzad 2021년 2월 7일
답변: Walter Roberson 2021년 2월 13일
I want to convert this data into the image shown after
paths = ["path1";"path2";"path3"];
cellData = {1,2,3,4;5,6,7,8;9,10,11,12};
How do I do this?
  댓글 수: 4
Siddharth Bhutiya
Siddharth Bhutiya 2021년 2월 8일
Do all rows have the same number of columns in your cell array data ?
Asim Shahzad
Asim Shahzad 2021년 2월 8일
@Siddharth Bhutiya yes they do.

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

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 13일
paths = ["path1";"path2";"path3"];
cellData = {1,2,3,4;5,6,7,8;9,10,11,12};
imageFilename = paths;
vehicle = cell2mat(cellData);
table(paths, vehicle)
ans = 3x2 table
paths vehicle _______ ___________________ "path1" 1 2 3 4 "path2" 5 6 7 8 "path3" 9 10 11 12
If you are going to put more than one group into the vehicle area, then instead
paths = ["path1";"path2";"path3"];
cellData = {1,2,3,4;5,6,7,8;9,10,11,12};
imageFilename = paths;
vehicle = num2cell(cell2mat(cellData),2);
table(paths, vehicle)
ans = 3x2 table
paths vehicle _______ ____________ "path1" {1×4 double} "path2" {1×4 double} "path3" {1×4 double}
you will not be able to get the actual numbers to display in that situation

추가 답변 (1개)

David Hill
David Hill 2021년 2월 8일
Why not just:
cell2mat(yourCellarray);
  댓글 수: 8
Walter Roberson
Walter Roberson 2021년 2월 13일
Perhaps Variable Browser shows them. The command window will not.
Asim Shahzad
Asim Shahzad 2021년 2월 13일
편집: Asim Shahzad 2021년 2월 13일
@Walter Roberson just checked. It does. Could you please post your comment as an answer so I can accept it? I'll edit my question with the updated images.

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by