help-octave
[Top][All Lists]

## Re: variables...

 From: Joao Cardoso Subject: Re: variables... Date: Wed, 15 Sep 1999 18:44:14 +0100

```Adam Balgach wrote:
>
> Ok, lets say i define a variable...
>
> f = "3*x^2+4*x+5"
> Octave changes that to f = 3*x^2+4*x+5 and im assumming that f is now a
> string (?)

octave:71> f = "3*x^2+4*x+5"
f = 3*x^2+4*x+5

octave:72> isstr (f)
ans = 1

> how would i go about searching for the positions of "x" in that string? im

octave:73> f == 'x'
ans =

0  0  1  0  0  0  0  0  1  0  0

octave:74> find(f == 'x')
ans =

3  9

> thinking way back to old basic commands like "left()" but i cant find any
> here in octave.  any thoughts? (also how would i display that string...when
> i define f as about and try..
>
> fprintf("string: "+f+"\n"); i get a ton of errors.

octave:75> printf("%s\n",f);
3*x^2+4*x+5

>
> thanks

Joao

>
>
> ---------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.  To ensure
> that development continues, see www.che.wisc.edu/octave/giftform.html
> Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> ---------------------------------------------------------------------

--
U.N. FORCES TO DILI, IMMEDIATELY
FREEDOM TO EAST TIMOR - TIMOR LOROSAE
------------------------------------------------------------
INESC, R. Jose Falcao 110   |   tel:    + 351 2 2094322
4050 Porto, Portugal        |   fax:    + 351 2 2008487

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure