problem with varargout...am I doing this correctly?

problem with varargout...am I doing this correctly?

Post by Jonathan K » Wed, 07 Dec 2005 21:09:50


In a program I am writing, I am trying to use varargout to contain
the number of matrices that I will need to graph in the next
function. For some reason, when I return varargout, I only get one
matrix and not all of them.

Then I wrote a simple program to test what was going on and I'm
getting the same thing. Can anyone help me out?

function [ output_args ] = testingvarargin( numberOfArgs )
%UNTITLED1 Summary of this function goes here
% Detailed explanation goes here

x = 0
x = callingArgs(numberOfArgs)
x

output_args = readingArgs(x)

function [varargout] = callingArgs(number)
%we'll use "number" to pass that number, times two or three,
arguments back
%using varargout...

if (mod(number, 2))
varargout = cell(1,3);
varargout(1) = {'Testing text'};
varargout(2) = {zeros(4,5)};
varargout(3) = {number};
else
varargout = cell(1,2);
varargout(1) = {'Testing text'};
varargout(2) = {eye(number)};
end
size(varargout)
varargout

function [output_array] = readingArgs(input_array)
%we'll now read in our previous varargout and see why this is doing
what
%it's doing.....

size(input_array)
output_array = input_array
 
 
 

problem with varargout...am I doing this correctly?

Post by Loren Shur » Wed, 07 Dec 2005 22:12:47

In article < XXXX@XXXXX.COM >, XXXX@XXXXX.COM
says...

You need to call your function with varargout with multiple output
values, e.g.,

[x,y,z,a,b,c,k] = callingArgs(numberOfArgs)

--Loren