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

1 visualizzazione (ultimi 30 giorni)
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]

Risposte (1)

Guillaume
Guillaume il 4 Nov 2019
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.

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by