MATLAB Answers

matrix with characters and numbers from text file

24 views (last 30 days)
polo Mahmoud
polo Mahmoud on 1 Nov 2019
Commented: polo Mahmoud on 4 Nov 2019
Hi, if I have a txt. file with 2 different matrix in the text. file and i want them to be read into matlab, eg:
this is from the txt. file:
% A =
[ 1 2 3 E
5 6 7 E]
% B =
[9 10 11 IX
13 14 15 IX]
and i want matlab to know the diffrent between these two element when it reads the file. so i can make them longer or shorter and it should still be able to take both matrix our with the characters and numbers
  4 Comments

Sign in to comment.

Answers (1)

Mil Shastri
Mil Shastri on 1 Nov 2019
You could use the import tool and even provide the url of the txt file (https://www.mathworks.com/matlabcentral/answers/uploaded_files/246014/coord2.txt)
You could then set the output type as a table/cell array/ whatever you like and then generate a script for it. You will notice that it eventually uses readtable with some options (not shown below)
% Import the data
coord21 = readtable("coord2.txt", opts);
  1 Comment
polo Mahmoud
polo Mahmoud on 4 Nov 2019
it does not work for me, it says in the table NaN to all the "letters", but it can load the numbers.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by