load txt file in matrix into matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
polo Mahmoud
el 2 de Jun. de 2020
Respondida: Ameer Hamza
el 2 de Jun. de 2020
how to load this into matlab from a txt file:
[1 2 1 E A Iy Iz Ix J
2 3 2 E A Iy Iz Ix J
3 4 3 E A Iy Iz Ix J]
the problem is that the letters E A Iy Iz Ix J ----> gives NaN when I load it into matlab
6 comentarios
madhan ravi
el 2 de Jun. de 2020
Rik probably he would need the letters for his symbolic computations. So the solution is to use textscan(...) as KSSV suggested.
Respuesta aceptada
Anish Walia
el 2 de Jun. de 2020
Since the data type of all values is not same, try importing it as cell array
data = readcell('testload.txt')
Más respuestas (1)
Ameer Hamza
el 2 de Jun. de 2020
As Madhan mentioned that you might want to load it as symbolic, you may try
str = fileread('test.txt');
words = regexp(str, '\w+', 'match');
idx = cellfun(@(x) isnan(str2double(x)), words);
syms(words(idx));
M = eval(str);
0 comentarios
Ver también
Categorías
Más información sobre Data Import and Export 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!