access value from another file

5 次查看(过去 30 天)
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???

采纳的回答

Image Analyst
Image Analyst 2014-3-28
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

更多回答(1 个)

Wayne King
Wayne King 2014-3-28
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

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by