help-octave
[Top][All Lists]
Advanced

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

Re: Small problem in a if condition


From: Geraint Paul Bevan
Subject: Re: Small problem in a if condition
Date: Sun, 01 Feb 2004 14:30:42 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031221 Thunderbird/0.4

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pol wrote:
| Hi there,
|
| I'm trying to convert that script from matlab to octave and I'm hurting
| my head on that script:
|
| function zp = kzp(v,z,i)
|
| if (v == '?')


You will need to use 'strcmp' to compare strings:


function zp = kzp(v,z,i)

if (strcmp (v, '?'))
~    d = z*i   ;
endif

if (strcmp (z, '?'))
~    d = v/i   ;
endif

if (strcmp (i, '?'))
~    d = v/z   ;
endif

M = norm(d) ;
P = angle(d)*180/pi ;
zp=[M;P];

endfunction



octave> kzp (1,'?',3)
ans =

~  0.33333
~  0.00000


- --
Geraint Bevan
http://homepage.ntlworld.com/geraint.bevan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iEYEARECAAYFAkAdDZEACgkQcXV3N50QmNN5RgCdGu5/Fhqoxa/mIaCjbVZ+GgGL
lWkAoIY77UZ8NiYo+5myDpGK5BMhX5DY
=CVtf
-----END PGP SIGNATURE-----



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