write data of textfile with different amount of value in cell array
2 次查看(过去 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
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
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 Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!