[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
newbie, problem using ranges with function...
From: |
luc . lefebvre |
Subject: |
newbie, problem using ranges with function... |
Date: |
Fri, 3 May 2002 16:42:08 -0400 (EDT) |
Hi,
I wrote this script:
#-------start-------
function M=f(x)
M=0;
if (x<6)
M=250*x;
else
M=250*x-2.5*250*(x-6);
endif
endfunction
x=(0:.1:10)'
data=[x, f(x)]
gplot data
#-------finish------
When I test the function f(x) manually (ie. f(0)=f(10)=0, f(6)=1500)
all is OK. When I do f(x) as above I get an output that is 3750
decreases monotonically by 37.5 for each value of x which is obviously
wrong.
Interestingly if I do sin(-pi:.1:pi) I get what would be expected.
There is obviously something that I am not getting...
tia
--
Luc Lefebvre o
/`-'
Open Source, a strategic choice \
for mission-critical applications ___/___./
Key fingerprint = D2E5 5E35 B910 6F4E 0242 EC63 0FD9 96D0 C7F4 784E
-------------------------------------------------------------
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
-------------------------------------------------------------
- newbie, problem using ranges with function...,
luc . lefebvre <=