From help-octave-request at bevo dot che dot wisc dot edu Sun Feb 1 08:29:36 2004 Subject: Re: Small problem in a if condition From: Geraint Paul Bevan To: Pol CC: help-octave at bevo dot che dot wisc dot edu Date: Sun, 01 Feb 2004 14:30:42 +0000 -----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 -------------------------------------------------------------