Using an array as an output

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 Commenti

per isakson
per isakson il 24 Set 2017
Modificato: per isakson il 24 Set 2017
"Simply writing [...] does not work". If "the elements y1, y2, y3, and y4" are scalars I cannot see why it shouldn't work.
It said that the variable is undefined. Maybe this is because it is an output?

Accedi per commentare.

Risposte (1)

Gaige
Gaige il 5 Ott 2023

0 voti

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?

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Richiesto:

il 24 Set 2017

Risposto:

il 5 Ott 2023

Community Treasure Hunt

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

Start Hunting!

Translated by