How to read data from text file and store as it is with variables
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have this data file, it goes like
phi1_32_1 = 1 phi2_32_1 = 32
phi1_32_2 = 1 phi2_32_2 = 33
phi1_32_3 = 1 phi2_32_3 = 34
phi1_32_4 = 1 phi2_32_4 = 35
phi1_32_5 = 1 phi2_32_5 = 36
... and so on.
I want to read this file into matlab and store as it is. Where for example
the phi1_31_1 is the name of the variable and the value stored in it is 1
the phi2_31_1 is the name of the variable and the value stored in it is 32
... and so on.
Any help is much appreciated. I thank those who would be taking their time to help me, in advance...
7 comentarios
Respuestas (1)
Rafael Hernandez-Walls
el 9 de Jun. de 2021
Editada: Rafael Hernandez-Walls
el 9 de Jun. de 2021
Assuming you have a file with only following line (name of file= 'algo.txt'):
phi1_32_1 = 1
You could then read the line with the following command:
fid=fopen('algo.txt','r');
a=fscanf(fid,'%s');
eval(a)
whos
I hope it is useful.
2 comentarios
Rafael Hernandez-Walls
el 9 de Jun. de 2021
You need put this idea in a while loop or something like..
Ver también
Categorías
Más información sobre Logical 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!