help-octave
[Top][All Lists]
Advanced

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

Re: creating a plot of a self-defined function


From: Erik Leunissen
Subject: Re: creating a plot of a self-defined function
Date: Mon, 17 Feb 2014 13:40:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 02/17/2014 01:24 PM, Juan Pablo Carbajal wrote:
Erik, note that a function of a matrix, like eigs (eigenvalues)
interprets a matrix as input as a single input value, i.e. the matrix
itself. But sometimes we want a user defined function to understand
that a matrix input represents a collection of input values where the
function should be evaluated, this is the "element-wise" case.

For example, you can create a discrete Fourier basis quite easily
(warning:this exploits automatic broadcasting, matlab doesn't do it)
t = linspace (0,2*pi,100).';
f = 1:10;
F = [sin(f.*t) cos(f.*t)];
subplot(2,1,1)
plot(t,F(:,1:10));
subplot(2,1,2)
plot(t,F(:,11:end));

Since the functions "sin" and "cos" interprets the input matrix "f.*t"
as a collection of arguments it evaluates on each entry of the matrix.


Thanks for being explicit about this. It's exactly where my preliminary understanding needed confirmation/focus.

Erik.


reply via email to

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