How can I get a value from another m file ?
1 view (last 30 days)
Show older comments
Hi , Lets say I have the following m file
function y = f1(x)
y = exp(x);
title = 'graph 1';
end
how can I access the variable (title) in my main m file ? for example using the title for a plot in my main file
0 Comments
Answers (1)
Geoff Hayes
on 6 Dec 2015
nero - return title as an output parameter from your call to the function
function [y,title] = f1(x)
Although, would the title always be 'graph 1', or could it be something different?
3 Comments
Geoff Hayes
on 6 Dec 2015
In your main m file, you would call the function as
[y,t] = f1(x);
passing your x into this function and obtaining the output parameters y and t (the title). How are you attempting to call the function now?
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!