i want to make a user input file where the matrix would be loaded into matlab

1 次查看(过去 30 天)
Hi i want a text file (txt-file) where the user eg. writes
txt file start:
A = 30;
IX = 10;
% A =
[ 1 2 3 IX
5 6 7 IX]
% B =
[ 1 2 3 A
5 6 7 A]
txt file end
and when you load this txt files in the matlab then i want the matlab to know what the matrix should look like:
% A =
[ 1 2 3 10
5 6 7 10]
% B =
[ 1 2 3 30
5 6 7 30]

回答(1 个)

Guillaume
Guillaume 2019-11-4
Just make it a .m file (and remove the %).
Of course, don't use A both as the constant 30 and as the name of a matrix. You can use any name you want for your variables you don't have to limit yourself to the 26 letters of the alphabet, and you certainly don't have to reuse the same name for different purposes.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by