Converting text file to array
177 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi.
I want to convert the text file (file attached below) into array of size 4X6. The array should not include the first row (containing characters).
Please help
1 comentario
Dyuman Joshi
el 20 de Oct. de 2023
If you have R2019a or later versions, the best approach is to use readmatrix, as Walter has specified.
Otherwise, readtable is the obvious choice.
Respuestas (2)
Walter Roberson
el 20 de Oct. de 2023
format long g
arr = readmatrix("WallContacts.txt")
0 comentarios
Ramtej
el 20 de Oct. de 2023
Hi mukesh,
I understand that you are trying to import text file data as an array.
In order to achieve this, you can follow below steps:
- Since, the data in the text file is in a table format. You can import the data as a table using "readtable" function and perform the desired operation on the table itself.
% import the text file as table
tbl = readtable("WallContacts.txt");
- Once you have imported the data as a table, you can convert it to an array using "table2array" functions as shown below.
% convert it into multidimensional array or matrix
arr = table2array(tbl);
Hope this resolves you query!!
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!