access value from another file

8 visualizzazioni (ultimi 30 giorni)
Jitesh Bhanushali
Jitesh Bhanushali il 28 Mar 2014
Commentato: Image Analyst il 28 Mar 2014
sir i have 2 m files one is
function mm
r=[1 2 3]
end
saved with name mm.m
the other is
function nn
% some code. I need r!
end
saved with name nn.m
I want to access value of r in file nn.m.
What is statement to access this r???

Risposta accettata

Image Analyst
Image Analyst il 28 Mar 2014
Have mm.m be this:
function r = mm()
r=[1 2 3]
end
And have nn.m be this:
function nn
% some code.
% Get r from mm():
r = mm;
end

Più risposte (1)

Wayne King
Wayne King il 28 Mar 2014
Why don't you have the function, nn.m, output the value of r, then the function mm can use that value. That is the best way to do it.
Alternatively, look at the help for global
  1 Commento
Jitesh Bhanushali
Jitesh Bhanushali il 28 Mar 2014
how to save vqlue r as r.m file n use it in another m file

Accedi per commentare.

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by