Using an array as an output

5 次查看(过去 30 天)
amateurintraining
amateurintraining 2017-9-24
回答: Gaige 2023-10-5
I have a function and the output must be a one-dimensional array consisting of the elements y1, y2, y3, and y4.
Do I have to make a subfunction or nested function in order to define the output?
Simply writing
output=[y1 y2 y3 y4]
does not work.
  2 个评论
per isakson
per isakson 2017-9-24
编辑:per isakson 2017-9-24
"Simply writing [...] does not work". If "the elements y1, y2, y3, and y4" are scalars I cannot see why it shouldn't work.
amateurintraining
amateurintraining 2017-9-24
It said that the variable is undefined. Maybe this is because it is an output?

请先登录,再进行评论。

回答(1 个)

Gaige
Gaige 2023-10-5
I would need to see all the code to be sure. Did you try seperating the elements with a coma, and was output the return falue of the function?

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by