Simple encapsulation of a function?

7 views (last 30 days)
Balaji
Balaji on 1 Jul 2014
Answered: Vishal_R on 3 Jul 2014
Hi all,
I have a simple question on the availability of a certain feature in Matlab. Let us say I have a script like the one below:
a= 1;
b= 2;
c= b+a;
What i want to do is
  1. select the third line.
  2. press a magic button.
Then matlab should creates a function like this
function c = autoGeneratedFunctionName(a,b)
c=a+b;
end
In essence matlab should identify the input and output variables of the selected block, and create a function file with them. Such a feature already exists in simulink (where you select a group of blocks, right click and ask matlab to make a subsystem out of the block).
Does this magic button exists?
Why am I asking for this feature? A huge number of people(I know 2, without including myself), do big scripts while development and later put chunks of code into manageable small functions once the script runs fine. This feature, if it exists, would save a lot of time.
Thanks for reading,
Balaji Sankar.

Answers (1)

Vishal_R
Vishal_R on 3 Jul 2014
This feature has not been supported as of now. There is no such magic button which will encapsulate your code.

Categories

Find more on Verification, Validation, and Test in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!