Please HELP!! Am I nuts?
Mostrar comentarios más antiguos
I define a function and save it:
function [new_x, new_y] = TestArray(x, y)
new_y = y.^2;
new_x = x;
end
At cursor I type:
x = 1:10
y = 1:10:30
Answer = TestArray(x, y)
I get:
Answer =
1 2 3 4 5 6 7 8 9 10
How on earth is this possible? I am feeling tired but I can only assume I am going crazy, tiredness cannot be a reason for this level stupidity?! Shouldn't i return an matrix with size [2x10]?
Respuesta aceptada
Más respuestas (2)
Hi,
this behavior is correct. In a function the output arguments aren't concatinated. They are returned as several outputs.
Try calling your function TestArray as
[Answer, Answer2] = TestArray(x, y)
If you want to have a 2x10 Matrix as output, then you need to concatinate it yourself inside the function.
Ali
el 7 de Nov. de 2012
0 votos
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!