From help-request at octave dot org Wed Jun 22 10:08:37 2005 Subject: Re: beginner question: returning matrix and other From: Quentin Spencer To: Jeff Abrahamson CC: help at octave dot org Date: Wed, 22 Jun 2005 10:05:05 -0500 Jeff Abrahamson wrote: >I have a function that wants to return a matrix and a scalar. The >most obvious way to do this doesn't work. Am I missing something? >Using cell's seems overkill. > > octave:45> a=ones(2,2) > a = > > 1 1 > 1 1 > > octave:46> b=3 > b = 3 > octave:47> [a,b] > error: number of rows must match (1 != 2) near line 47, column 4 > > > The command "[a,b]" is trying to concatenate the matrices a and b, which are different sizes in your example. On the other hand, something like "[a,b] = myfunc(c)" returns a and b as outputs of the function myfunc if the function myfunc is defined. Try the following example: function [output1, output2] = myfunc(input); output1 = ones(2,2); output2 = input; endfunction Entering "[a,b] = myfunc(3)" should return the values of a and b you gave in your example. Hope this helps. -Quentin ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------