[Top][All Lists]

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

RE: Arrays: Multidimensional manipulating

From: William Krekeler
Subject: RE: Arrays: Multidimensional manipulating
Date: Tue, 12 Apr 2011 16:33:53 +0000

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of dirac
Sent: Tuesday, April 12, 2011 11:23 AM
To: address@hidden
Subject: Arrays: Multidimensional manipulating

Hi there,

I am having problems with a multidimensional array at the moment and have
looked online to see similar problems...

I basically have an equation

p = exp(-1*(a*(|k|^b)))

which I write:

p = exp(-1*abs(k).^b).

This is simple enough so far; if I want to vary a, k, and b, I could use for
loops or I could do it using a multidimensional array (what I want to do as
I assume it'll be faster). I started by defining vectors for a, b, and k:

k = [-20:0.05:20];
b = [0:0.01:2];
a = [0:0.001:0.01];

and then tried to find p for all of the possible values of a, b and k and
store in an array of three dimansion; I tried this:

p = zeros(length(a),length(k),length(b));   %allocating memory

p = exp(-1.*a.*(abs(k)).^b)

Which doesn't seem to work. 
Is this something that you can do with Octave or will I have to use for

Thanks in advance

Still learning everyday.
View this message in context:
Sent from the Octave - General mailing list archive at
Help-octave mailing list


Maybe you could try using meshgrid.

[A,B,K] = meshgrid(a,b,k);
p = size(A);
p = exp(-1.*A.*(abs(K)).^B);

William Krekeler

reply via email to

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