help-octave
[Top][All Lists]
Advanced

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

Re: strange behaviour of .*


From: Ben Abbott
Subject: Re: strange behaviour of .*
Date: Sat, 22 May 2010 12:04:31 -0400

On May 22, 2010, at 11:31 AM, Miĥail Vasiljev wrote:

> Hello, octave-users!
> 
> I have a script, which I think is correct, but it does not work in GNU
> Octave. Could you, please, explain me whats wrong with it? I've removed
> all the code that is not related to the problem from the script, and
> applied it to the message. "Main_vec.m" calls "fsolve()" and passes it
> the "trovuTemperaturoj" function. After that my octave complains:
> 
> 
>> [xinm]:~/calc/teilor
>> :./main_vec.m
>> error: product: nonconformant arguments (op1 is 1x998, op2 is 998x1)
>> error: evaluating binary operator `.*' near line 12, column 42
>> error: evaluating assignment expression near line 11, column 28
>> error: called from `trovuTemperaturoj' in file 
>> `/home/xinm/calc/teilor/trovuTemperaturoj.m'
>> error: fsolve: evaluation of user-supplied function failed
>> error: near line 7 of file `./main_vec.m'
>> 
> 
> Whats wrong with my script? Why op1 ((1./r(2:numberOfElements-1)) as I
> understand) is 1x998 and op2 (((u(2+numOfEl-1:numOfEl-1+numOfEl-1) - u(2
> +numOfEl:numOfEl-1+numOfEl))./(Delta_r))) is 998x1? I use GNU Octave,
> version 3.0.1 from Debian Lenny repository. 
> 
> Thank you!

I tried your example with Octave 3.2.3 and the developer's sources. In each 
case there was no error.

I inserted the followiing in your function

  a = r(2:numberOfElements-1);
  b = (u(2+numOfEl-1:numOfEl-1+numOfEl-1) - \
       u(2+numOfEl:numOfEl-1+numOfEl))./(Delta_r);
  whos a b

Which gave

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  ===== 
       a           1x998                     7984  double
       b           1x998                     7984  double

If you can, I suggest you update your version of Octave.

I'd guess that fsolve is changing the orientation of the input vector, u. You 
can try to see if adding the line below to trovuTemperaturoj.m fixes the 
problem.

        u = reshape (u, [1, numel(u)]);

Ben





reply via email to

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