Borrar filtros
Borrar filtros

Create n variables based on a int input

3 visualizaciones (últimos 30 días)
Roberto Antonino Ruggeri
Roberto Antonino Ruggeri el 28 de Nov. de 2019
Comentada: Walter Roberson el 28 de Nov. de 2019
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!

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Nov. de 2019
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.

Categorías

Más información sobre Variables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by