Info

This question is closed. Reopen it to edit or answer.

returning an array argument

3 views (last 30 days)
John Lofgren
John Lofgren on 16 Feb 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
I am returning a double array, inst_array, from a function:
function [inst_array, pass ] = ....
In the called function, the return argument looks correct, I explicitly assign it.
But If I stop the debugger just after returning, the returning variable holds the incorrect double values. It is dimensioned correctly, and some values are incorrect.
  1 Comment
the cyclist
the cyclist on 16 Feb 2012
Are you able to distill this into a small problem that you can post here? You're not really giving us much to go on. :-)

Answers (1)

John Lofgren
John Lofgren on 16 Feb 2012
I will do that. It is clearly ok for Matlab to return an array, right?
  2 Comments
Walter Roberson
Walter Roberson on 16 Feb 2012
Absolutely definitely Yes.
function foo = bar()
foo = magic(5);
end
James Tursa
James Tursa on 16 Feb 2012
Yes. MATLAB can return any variable, including an array.

Community Treasure Hunt

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

Start Hunting!