[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Few questions (convolutions, 'mapping', linspace)
From: |
Przemek Klosowski |
Subject: |
Few questions (convolutions, 'mapping', linspace) |
Date: |
Mon, 16 May 1994 13:18:06 -0400 |
Hi,
I have a couple of questions that came in my recent using of Octave; I wonder
if anyone could help:
- I want to convolute the theoretical function S(Q,w) with the experimental
resolution r(w), to compare the resulting Sr(Q,w) with experimental data.
The formula is:
w0
/
Sr(Q,w) = | S(Q,w-v) r(v) dv
/
-w0
I was hoping to use the quad("fun",-w0,w0), where fun would be defined
as 'function y=fun(x); y=S(Q,w-x)*r(x); endfunction'. This didn't quite
work, as I need to access Q,w from within that function. I can't pass
them as parameters of fun() because quad() expects only one-parameter fun;
I couldn't figure the way to pass them as globals either.
- I often find myself defining a function (y=fun(x)), and hoping to be able
to 'map' (in the LISP sense) the vectors/matrices with this function, for
instance to plot it. The naive approach, y=f(x) for a vector/matrix 'x',
does not result in
y = [f(x(1)), f(x(2)), f(x(3)) ... f(x(N))],
which is fine because the arithmetic operators in the function definition
have meaning for matrices as well. For vector 'x' I can always do
for i=1:length(x); y(i)=f(x(i)); endfor
but I wonder if there is a neater, general way. I suppose I could be defining
my functions to do the explicitly recognize vector arguments, but
that still leaves the question whether I have to write explicit 'for' loops
or is there a better way.
- I noticed that the linspace operator is fairly slow: linspace(-1,1, 10000)
takes
25 seconds on a 150MHz r4400, while the a=(0:.0001:1); is very quick, and
the
FFT of the resulting matrix is only few seconds. What is the advantage of
linspace
over the range operator, and why is it so slow?
Greetings
przemek
- Few questions (convolutions, 'mapping', linspace),
Przemek Klosowski <=
- Re: Few questions (convolutions, 'mapping', linspace), John Eaton, 1994/05/16
- Re: Few questions (convolutions, 'mapping', linspace), John Eaton, 1994/05/16
- Re: Few questions (convolutions, 'mapping', linspace), John Eaton, 1994/05/16