help-octave
[Top][All Lists]
Advanced

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

Simple array question


From: Terry Letsche
Subject: Simple array question
Date: Sun, 25 May 2003 21:38:50 -0500 (CDT)

Hello. I'd like to iterate with a for loop to fill an array with values, 
but I'm having troubles on a couple fronts.

1) I take it it's not possible to have an array subscribt of 0 with the 
2.1.42 release (running under windows)??

2) Here's something like I'd like to do (generating matrices to do signal 
processing with wavelets):

The code I'm trying to convert is Matlab code, so some thing like using 
n.0 as a variable name don't seem to be allowed, so I thought the next 
most logical thing would be to put it those values in an array.

k=5;
n(0) = 2^k;
for t = 1:k
   n(t) = n(0) / 2^t;   %% I get an error here about scalars?? 
endfor;

Here's the original code. I think I'm going to have another problem with 
the call to the matrix function?

k:=5: n.0:=2^k: for t from 1 to k do n.t:=n.0/2^t: od:
for t from 0 to k-1 do M.t:=matrix(n.0,n.0,proc(i,j) if \
   (i<=(n.t/2) and (2*i-1)<=j and j<=(2*i)) then (1/2) elif \
   (i>(n.t/2) and i<=n.t and (2*(i-n.t/2)-1)<=j and j<=(2*(i-n.t/2))) \
   then (1/2)*(-1)^(j+1) elif \
   (i>n.t and i=j) then 1 else 0 fi end: od:
M:=M.0: A:=inverse(M.0):
for q from 1 to k-1 do M:=multiply(M.q,M):
A:=multiply(A,inverse(M.q)): od:

Here's my stab at converting it so far:
k=5;
nz = 2^k;     %% call n.0 nz for n-zero
for t = 1:k
   n(t) = nz/2^t; %% this gives an error??
endfor;
for t = 0:k-1
   M(t) = ??(nz, nz, ????? after this I'm lost!)

If any one could point to me any tips or help me out, I'd appreciate it!

Thanks.

Terry
-- 
Terry Letsche  | http://terry.letsche.net | terry at letsche dot net




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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