help-octave
[Top][All Lists]
Advanced

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

Looping over two equal length cell arrays?


From: fork
Subject: Looping over two equal length cell arrays?
Date: Fri, 30 Apr 2010 22:54:07 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hi

Is there a nice way to loop over two equal length cell arrays, like in Python or
Tcl?  I know how to do it with an integer index based on the length of one of
the cell arrays, I just don't like that syntax.

I want to use it to populate a struct, which there might be a better way to do
anyway.

This is what I want to do:

s = struct()
keys = {'a', 'b', 'c'}
vals = {1,2,3}
for k = keys, v = vals
    s = setfield(s, k, v);
endfor
s.a == 1




reply via email to

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