Access to a file when running the program
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, i have to files .m in the same folder. One is used to run the main program and the other is used just to put the information input for the program.
p.e:
one file is the main.m and the other is info.m
info.m is similiar to this:
Volume_inicial = 900000000; Volume_final = 900000000; Volume_min = 800000000; Volume_max = 1000000000; Caudal_turb_max = 400; Caudal_bomb_max = 400;
Now, in the main.m i wanna be able to pick this data. How can i pick just Volume_inicial p.e?
0 comentarios
Respuesta aceptada
Muruganandham Subramanian
el 14 de Dic. de 2012
Editada: Muruganandham Subramanian
el 14 de Dic. de 2012
Or You can declare as global variable like global Volume_inicial in your info.m file
and if you want to access particular file info, use open() command
e.g. open(D:\Users\programfiles\myfolder\info.m')
3 comentarios
José-Luis
el 14 de Dic. de 2012
Editada: José-Luis
el 14 de Dic. de 2012
This is not a good idea, I would even say terrible. You can just call one script from another.
Main.m could look like this:
%Hi, I am main
%Load your data
info
%Do your stuff
Note that once you load your info, you can save it to other variables and could even do this dynamically
If you want to get fancier, look at the run() command
Más respuestas (1)
Vishal Rane
el 14 de Dic. de 2012
You could simply run the other file, thus loading its contents in the workspace and use any variables you need.
1 comentario
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!