octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60816] In a user created function if i pass a


From: anónimo
Subject: [Octave-bug-tracker] [bug #60816] In a user created function if i pass a vector it is incorrectly evaluated
Date: Wed, 23 Jun 2021 22:59:24 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?60816>

                 Summary: In a user created function if i pass a vector it is
incorrectly evaluated
                 Project: GNU Octave
            Submitted by: None
            Submitted on: jue 24 jun 2021 02:59:22 UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Rosa María Valdespino
        Originator Email: rosemeer@yahoo.com.mx
             Open/Closed: Open
                 Release: 4.2.2
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

>> function y = momen(x)
if (x <= 3)
y = 75 .* x .- 20 .* x .**2 ./ 2 ;
else
y = 75 .* x .- 20 .* x .** 2 ./2 .- 30 .* (x .- 3);
endif
endfunction

x = linspace(0, 6, 9);
>> x
x =

   0.00000   0.75000   1.50000   2.25000   3.00000   3.75000   4.50000  
5.25000   6.00000

>> z = momen(x);
>> z
z =

 Columns 1 through 7:

    90.00000   118.12500   135.00000   140.62500   135.00000   118.12500   
90.00000

 Columns 8 and 9:

    50.62500     0.00000

<z = momen(x) >===> This is incorrect/>

>> momen(0), momen(0.75), momen(1.5), momen(2.25), momen(3), momen(3.75),
momen(4.5), momen(5.25), momen(6)
ans = 0
ans =  50.625
ans =  90
ans =  118.12
ans =  135
ans =  118.12
ans =  90
ans =  50.625
ans = 0
>> < by "hand" momen(i) is correct />

Other data
GNU Octave, version 4.2.2

Processor intel(R) Celeron(R) M CPU 4730 @ 1.73 GHz (32 bits)

Kernel linux 4.15.0-122-generic(i686)
Ubuntu Mate 16.04.06




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60816>

_______________________________________________
  Mensaje enviado vía Savannah
  https://savannah.gnu.org/




reply via email to

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