Functions | |
function | fplot (fn, limits, n, linespec) if(nargin< 2||nargin > 4) print_usage() |
endif | if (nargin< 3) n=0.002 |
endif | if (ischar(n)) have_linespec |
endif | if (strcmp(typeinfo(fn),"inline function")) fn |
elseif (isa(fn,"function_handle")) nam | |
elseif (all(isalnum(fn))) nam | |
endif | if (floor(n)!=n) tol |
while (n< 2.^20) y00 | |
endif | if (have_linespec) plot(x |
else | plot (x, y) |
endif | if (length(limits) > 2) axis(limits) |
endif | if (isvector(y)) legend(nam) |
endfor | legend (nams{:}) |
endif endfunction!demo | !fplot ("cos",[0, 2 *pi])%!demo%!fplot("[cos(x) |
endif endfunction!demo | sin (x)]" |
Variables | |
endif | have_linespec = true |
linespec = n | |
n = 0.002 | |
nam = formula (fn) | |
else | fn = vectorize (inline (fn)) |
x0 = linspace (limits(1), limits(2), 5)' | |
y0 = feval (fn, x0) | |
err0 = Inf | |
x = linspace (limits(1), limits(2), n)' | |
y = feval (fn, x) | |
err = 0.5 * max (abs ((y00 - y) ./ (y00 + y))(:)) | |
else for | i |
endif endfunction !demo !fplot | ( | "cos" | ) |
elseif | ( | isa(fn,"function_handle") | ) |
endif if | ( | isvector(y) | ) |
endif if | ( | length(limits) | , | |
2 | ||||
) |
endif if | ( | have_linespec | ) |
endif if | ( | floor(n)! | = n |
) |
endif if | ( | ischar(n) | ) |
endif if | ( | ) | [pure virtual] |
endfor legend | ( | ) |
else plot | ( | x | , | |
y | ||||
) |
endif endfunction !demo sin | ( | x | ) |
while | ( | ) |
err = 0.5 * max (abs ((y00 - y) ./ (y00 + y))(:)) |
err0 = Inf |
endif have_linespec = true |
n = 0.002 |
endif x0 = linspace (limits(1), limits(2), 5)' |