From help-octave-request at bevo dot che dot wisc dot edu Sun Feb 1 11:18:43 2004 Subject: Small problem in a if condition From: "John W. Eaton" To: Pol Cc: help-octave at bevo dot che dot wisc dot edu Date: Sun, 1 Feb 2004 11:12:27 -0600 On 1-Feb-2004, Pol wrote: | 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 == '?') | d = z*i ; | endif | | if (z == '?') | d = v/i ; | endif | | if (i == '?') | d = v/z ; | endif | | M = norm(d) ; | P = angle(d)*180/pi ; | zp=[M;P]; | | endfunction | | And now the errors: | | octave:1> kzp(1,'?',3) | error: invalid conversion from string to real matrix | error: type conversion failed for binary operator `==' | error: evaluating binary operator `==' near line 7, column 7 | error: if: error evaluating conditional expression | error: evaluating if command near line 7, column 1 | error: called from `kzp' in file `/home/pol/.octave/m/kzp.m' What version of Octave are you using? I think the == operator should work for character strings with either 2.0.17 or 2.1.50. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------