Execute text files in matlab
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My text files look like:
a = [1, 2, 3, 4, 5]
b = [6, 7, 8, 9, 10]
I want to basically run my text files as if they’re just .m files, and use the variables defined in the text files.
Or is there a way I could just import the variables from these text files?
2 comentarios
Walter Roberson
el 1 de Dic. de 2018
Perhaps you might be interested in https://www.mathworks.com/matlabcentral/fileexchange/17177-ini2struct
Respuestas (1)
Mark Sherstan
el 30 de Nov. de 2018
Make a text file that looks like this and call it "test.txt":
1, 2, 3, 4, 5
6, 7, 8, 9, 10
Use the following function to load it into MATLAB
load test.txt
Then seperate out your data into its variables:
a = test(1,:);
b = test(2,:);
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!