フィルターのクリア

Create n variables based on a int input

3 ビュー (過去 30 日間)
Roberto Antonino Ruggeri
Roberto Antonino Ruggeri 2019 年 11 月 28 日
コメント済み: Walter Roberson 2019 年 11 月 28 日
Hi I've a function to generale a spline curve.
I need to repeat this function several times in order to create curve1, curve2, curve3, curve4 and so on.
How can I define only 1 function which takes as input the number of curves I want to create and returns all the variables calculated in the function as:
pointsofcurve1=[...]
curve1=[...]
pointsofcurve2=[..]
curve2=[...]
and so on..?
Last number of all the variables inside the function such as pointsofcurveX, curveX needs to be created automatically in order to generate all the variables of each curve and the curve itself.
Thank you very much!

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 28 日
You cannot. It is only possible to return as many variables as the user provided space for when they called the function.
You can use nargout to test how many return variables the user asked for.
You do not need to name the output variables individually. Instead you can use the special name varargout and treat it like a cell array. Assign to varargout{K} to assign to the Kth output variable.

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by