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

1 Ansicht (letzte 30 Tage)
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 Kommentar
Sam
Sam am 1 Jul. 2021
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sam
Sam am 1 Jul. 2021
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

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by