help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do get a return value from a subroutine into the workspace?


From: Joe Koski
Subject: Re: How do get a return value from a subroutine into the workspace?
Date: Wed, 05 May 2004 21:14:53 -0600
User-agent: Microsoft-Entourage/10.1.4.030702.0

on 5/5/04 8:38 PM, Henry F. Mollet at address@hidden wrote:

> I'm running a main program (function) with a call to a subprogram (another
> function) that I have modified (removing ";" after the call)  so that the
> return value ,a matrix called "A", will get printed to the screen. How do I
> get "A" into the workspace? I have to copy/paste "A" into an editor, save it
> as "A", then load "A" into the workspace but there must be an easier/better
> way to accomplish this?  The return values of the main program are in the
> workspace after running the program and they are also printed to the screen
> if I remove the ";" after the call at the octave prompt.
> Henry
> 
You set it up in the function call. For example, here's the first line of a
function

function [A,f,tt] = hhspectrum(imf,t,l,aff)

And here is the line that gets the values A,f,tt back to the calling program

[A,f,tt] = hhspectrum(imf,t,l,0);

In the calling program, you could change the names to be different from
those in the function, if desired, e. g.,

[B,g,ttt] = hhspectrum(imf2,tx,m,0);

It's the position in the list that matters, not the actual variable name.

Joe





-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]