Simple encapsulation of a function?

6 次查看(过去 30 天)
Balaji
Balaji 2014-7-1
回答: Vishal_R 2014-7-3
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.

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Verification, Validation, and Test 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by