write data of textfile with different amount of value in cell array

조회 수: 1 (최근 30일)
Bruce Rogers
Bruce Rogers 2021년 7월 1일
댓글: Bruce Rogers 2021년 7월 1일
Hello everyone,
I wanted to ask if there is a possibility to create a matrix/cell array with different amount of rows? I'm trying to get the fourth column of the attached files into one matrix/cell array, but it doesn't work.
here is my attempt:
irl = readtable("min_vel12_halfpi.txt");
z_irl_temp = irl{:,4};
z_irl{:,1} = z_irl_temp;
irl = readtable("min_vel12_1pi.txt");
z_irl_temp = irl{:,4};
z_irl{:,2} = z_irl_temp;
irl = readtable("min_vel12_2pi.txt");
z_irl_temp = irl{:,4};
z_irl{:,3} = z_irl_temp;
irl = readtable("min_vel12_4pi.txt");
z_irl_temp = irl{:,4};
z_irl{:,4} = z_irl_temp;
irl = readtable("min_vel12_8pi.txt");
z_irl_temp = irl{:,4};
z_irl{:,5} = z_irl_temp;
but I keep getting this error code:
Unable to perform assignment because brace indexing is not supported for variables of this type.
How can I solve this problem? Thanks for your ideas and your help!
  댓글 수: 1
Sam
Sam 2021년 7월 1일
Matrices can't be used for different row sizes. Use cell array to do so.
z_irl = cell(1,5);
irl = readtable("min_vel12_halfpi.txt");
z_irl_temp = irl{:,4};
z_irl{1,1} = z_irl_temp;
%similarly add values for z_irl{1,2}, z_irl{1,3}, z_irl{1,4} and so on

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

채택된 답변

Sam
Sam 2021년 7월 1일
Matrices can't be used for different row sizes. Use cell array to do so.
z_irl = cell(1,5);
irl = readtable("min_vel12_halfpi.txt");
z_irl_temp = irl{:,4};
z_irl{1,1} = z_irl_temp;
%similarly add values for z_irl{1,2}, z_irl{1,3}, z_irl{1,4} and so on

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by