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

3 次查看(过去 30 天)
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 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by