|
From: | Isak Delberth Davids |
Subject: | Re: Create Structure |
Date: | Sun, 12 Jun 2016 10:34:00 +0200 |
On 06/11/2016 11:51 PM, Thomas D. Dean wrote:
I have a character array with 156 names and a corresponding array of
values;
octave:341> a=["n1";"n2";"n3"]
octave:342> b=[1;2;3]
octave:343> x=struct(a(1,1:2),b(1),a(2,1:2),b(2),a(3,1:2),b(3))
octave:344> x
x =
scalar structure containing the fields:
n1 = 1
n2 = 2
n3 = 3
Is there a function to do this? Do I have to go to an oct file?
I have looked at cellfun, and structfun, but, could not make either
work. Most likely, I do not understand this...
x=struct()
for idx=1:3
x = setfield(x,a(idx,1:3),b(idx))
endfor
Tom Dean
_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |