help-octave
[Top][All Lists]
Advanced

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

Re: How Do I Create a Map With Indexed Values in an Oct File


From: Thomas D. Dean
Subject: Re: How Do I Create a Map With Indexed Values in an Oct File
Date: Thu, 08 Apr 2010 11:43:45 -0700

> Create a 2-element cell array (Cell), add the s's to it, and use 
> t.assign("h", the-cell-array);


This results in a different index...

In octave,
  x.a=1;
  x.b=2;
  a.h{1}=x;
  x.a=11;
  x.b=12;
  a.h{2}=x;
  a.idx=2;


In f.cc
  octave_value_list retval;
  Cell c(2,1);
  Octave_map s, t;
  octave_value_list cellIdx(1,1);
  octave_value_list& pCellIdx = cellIdx;
  s.assign("a",1);
  s.assign("b",2);
  c.assign(pCellIdx,Cell(s));
  s.assign("a",11);
  s.assign("b",12);
  cellIdx(0)=2;
  c.assign(pCellIdx,Cell(s));
  t.assign("h",c);
  //t.assign("nnn",2);
  retval(0) = t;
  return retval;

In octave
octave:1>  y=f
octave:2> y
y =
{
  2x1 struct array containing the fields:

    h
}
octave:3> y.h(1)
error: can't perform indexing operations for cs-list type
octave:4  y(1).h
ans =
{
  a =  1
  b =  2
}

Also, in f.cc, if I use
  t.assign("idx",2)
it compiles Ok.

In octave
octave:5> y=f
error: invalid structure assignment






reply via email to

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