how to generate a string from the function content besides running it

5 ビュー (過去 30 日間)
S H
S H 2019 年 5 月 27 日
コメント済み: S H 2019 年 5 月 27 日
Could you help me by adding some scripts to any function that will create a string from the function contents besides running the function?
For example, the following function will only generate 35 for test(10). I want it also to generate str as I have provided below.
.
.
.
function c=test(a)
b=a.'+2;
%disp('linear mode')
c=3*b-1;
end
.
.
.
The new function should be able to run as [out,str]=test(10) and provide the following result.
out =
35
str =
3×1 cell array
{["b=a.'+2;" ]}
{["%disp('saturation region')"]}
{["c=3*b-1;" ]}
  18 件のコメント
Walter Roberson
Walter Roberson 2019 年 5 月 27 日
A class must be in its own file(s) .
scripts can include functions as of R2016b.
S H
S H 2019 年 5 月 27 日
Thank you Geoff and Walter for introducing class. I will read about it and see how I can modify my gui output to benefit from class offerings.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by