[scilab-Users] help needed for a grep in a multidimensional struct array

Gianluca Antonelli antonelli1970 at gmail.com
Thu Feb 11 14:37:43 CET 2010


Dear Mathieu,

thanks for your reply.

I tried the synthax you suggest and the output is always empty. Below a 
simple code to verify it.

I know that it is very simple to build a customized grep-like function 
but my real 3-dimensional struct array is quite large and I'm worried 
about computational time.

Here is a not-working sample code:

-----------------------
-->N=10;for i=1:N; for j =1:N; for k=1:N; slot(i,j,k).cdl=""; 
slot(i,j,k).modulo=""; end; end; end

-->slot
  slot  =

10x10x10 struct array with fields:
    cdl
    modulo

-->slot(1,2,3).cdl="abc";

-->find(slot.cdl=="abc")
  ans  =

      []
----------------------

Best,
g.



Mathieu Dubois wrote:
> Hello Gianluca,
> 
> Did you try a simple:
> find(slot.cdl=="abc")
> 
> It should not be difficult to turn this in a function...
> 
> Mathieu
> 
> Gianluca Antonelli wrote:
>> Hi,
>>
>> I have the following problem.
>>
>> I have the following variable:
>>
>> slot  =
>>
>> 30x5x10 struct array with fields:
>>    modulo
>>    cdl
>>
>> I need to find all the indexes for which the field cdl matches a
>> specific grep command.
>>
>> I would like to know if is it possible to have a function such as:
>>
>> out = grep(slot.cdl, "abc")
>>
>> Any hint?
>>
>> Thanks in advance,
>> g.
> 
> 




More information about the users mailing list