help-octave
[Top][All Lists]
Advanced

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

Re: send octave output to string


From: charles reid
Subject: Re: send octave output to string
Date: Sun, 7 Sep 2008 17:40:49 -0600

Hi -

I just replied to Bill but forgot to cc the mailing list.  I found a workaround that is working for me.  I turned off the "less" pager (using the command "more off"), which then redirects Octave's output to stdout instead of to "less".  This allowed me to capture the output.


Charles

On Sun, Sep 7, 2008 at 5:38 PM, Ben Abbott <address@hidden> wrote:

On Sep 7, 2008, at 7:17 PM, Bill Denney wrote:

charles reid wrote:
Hi there -

I've been searching Octave documentation & the web with no luck on
this, so I thought I would ask here.  If I want to send the output of
an Octave command to a string, how would I do that?  For example, if I
type

a = 2 + 2

And I want a string to contain the resulting " a = 4 ", how would I do
that?  Thanks!

You're looking for num2str or sprintf:

num2str(a)

or

spritnf("%d", a)

Have a good day,

Bill

If you want the "a =" part as well.

str = sprintf ("a = %d", a);

Or do you want to capture the output to the console for a specific command?

I dont' know how to do that, anyone else?

Ben



reply via email to

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