Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
passing variables between m files

Subject: passing variables between m files

From: Mateusz Gos

Date: 29 Nov, 2010 22:55:05

Message: 1 of 2

hi,

as mentioned above i'm passing variables between m files. because they are not the 'final otputs' and I do not want to modify a matlab build-in routines, in order to pass some of the 'intermediate' variables i am forced to save them to a mat file and load it in a next m file. i'm tempted to substitute it with a global cell (if possible) and save these variables to it so they can be passed without producing any output files in the process.
in other cases i'm forced to save the intermediate steps via fprintf building a sort of matrix (in form of a text file) which i then, at the end, process. would it be better to save each iteration to a global matrix rather then this text file? (once again - would save producing an intermediate output which I eventually have to delete anyway)

cheer for the advice,
mateusz

Subject: passing variables between m files

From: ImageAnalyst

Date: 29 Nov, 2010 23:05:31

Message: 2 of 2

Either way would work, and deleting a file or clearing a global
variable (to clean up after yourself) is just a single line of code
either way, so just go with a way that you're most comfortable with.
I think some people would recommend the variable (no disk file)
method, but I think everyone has used temporary disk files at some
point so it's not taboo., So I'd just go with what you think is
simplest to get the job done. That's my two cents.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us