Structure size inside another structure in Matlab (R2010a 64-bit Linux)

I work with the Matlab API, which loads data from a proprietary format into a number of structures. Here is an example of what the data set looks like after downloading the file:

<P →> field names (data (1))

ans =

'Grid_Point_ID'
'Grid_Point_Latitude'
'Grid_Point_Longitude'
'Grid_Point_Altitude'
'Grid_Point_Mask'
'BT_Data'

→ data (1) .BT_Data p>

ans =

BT_Data: [1x66 struct]

→ fieldnames (data (1) .BT_Data (1))

ans =

'Flags'
'BT_Value_Real'
'BT_Value_Imag'
'Pixel_Radiometric_Accuracy'
'Incidence_Angle'
'Azimuth_Angle'
'Faraday_Rotation_Angle'
'Geometric_Rotation_Angle'
'Snapshot_ID_of_Pixel'
'Footprint_Axis1'
'Footprint_Axis2'

I want to go over everything data(i).BT_Data(j). I already have the length datafine, but I cannot get the size / length BT_Data(which varies for each data(i)):

→ length (data (1) .BT_Data)

ans =

 1

→ size (data (1) .BT_Data)

ans =

 1     1

My expected result is here ans = 66(or an equivalent array for size()).

, . length(data) , , BT_Data ( BT_Data(:)).

, , - 1757250, ( , ). , .

------ EDIT ------

, API, , :

→ system ('ln -sf/opt/rwapi-matlab/lib/rwapi/smos/config/xml_rw_api.usr_conf.xml.');
SetEnv ( 'XML_RW_API_HOME', '//rwapi-Matlab/Library/rwapi');
(, '/Opt/rwapi-MATLAB');

→ prod = RWAPI.product('SM_OPEB_MIR_SCLF1C_20110202T013659_20110202T014642_346_060_1')

SMOS Matlab 1.4
(c) 2010 Array Systems Computing Inc. (http://www.array.ca)
Array

prod =

RWAPI.product handle
Package: RWAPI

Properties:
     filename: 'SM_OPEB_MIR_SCLF1C_20110202T013659_20110202T014642_346_060_1'
       header: [1x1 struct]
xml_datablock: []

, ,

→ data = prod.dataset(2)

data =

RWAPI.dataset .   : RWAPI

, ,

→ (1)

ans =

       Grid_Point_ID: 251721
 Grid_Point_Latitude: 25.5000
Grid_Point_Longitude: -102.2590
 Grid_Point_Altitude: 1.4714e+03
     Grid_Point_Mask: 2
             BT_Data: [1x66 struct]

→ (1).BT_Data​​p >

ans =

BT_Data: [1x66 struct]

→ (1).BT_Data (1)

ans =

                     Flags: 6229
             BT_Value_Real: 262.5275
             BT_Value_Imag: 0
Pixel_Radiometric_Accuracy: 6160
           Incidence_Angle: 31966
             Azimuth_Angle: 10299
    Faraday_Rotation_Angle: 65277
  Geometric_Rotation_Angle: 58605
      Snapshot_ID_of_Pixel: 65752530
           Footprint_Axis1: 19649
           Footprint_Axis2: 14625

→ whos

ans 1x1 1
   1x19091 112 RWAPI.dataset
  prod 1x2 112 RWAPI.product

+3
3

, , overrridden subsref RWAPI. , .

classdef stupidref
    %STUPIDREF Reproduce odd indexing behavior that jpatton saw. Buggy.
    properties
        BT_Data = repmat(struct('foo',42, 'bar',42), [1 66]);
    end
    methods
        function B = subsref(A,S)
            s = S(1);
            subs = s.subs;
            chain = S(2:end);

            switch s.type
                case '()'
                    B = builtin( 'subsref', A, s );
                    if ~isempty(chain)
                        B = subsref(B, chain);
                    end

                case '.'
                    % Non-standard behavior!
                    if ~isempty(chain) && isequal(chain(1).type, '()')
                        B = subsref(A.(s.subs), chain);
                    else
                        B = struct(s.subs, A.(s.subs));
                    end
            end
        end
    end
end

data(1).BT_Data fieldnames(data(1).BT_Data(1)) , ".BT_Data".

>> data = stupidref;
>> data(1).BT_Data
ans = 
    BT_Data: [1x66 struct]
>> fieldnames(data(1).BT_Data)
ans = 
    'BT_Data'
>> fieldnames(data(1).BT_Data(1))
ans = 
    'foo'
    'bar'
>> length(data(1).BT_Data)
ans =
     1
>> data(1).BT_Data.BT_Data.BT_Data.BT_Data.BT_Data.BT_Data % produced by tab-completion
ans = 
    BT_Data: [1x66 struct]
>> 

- a = data(1).BT_Data, , . getfield.

>> btdata = getfield(data(1).BT_Data, 'BT_Data')
btdata = 
1x66 struct array with fields:
    foo
    bar

RWAPI.

; , .

+2

, :

→ a = (1).BT_Data​​p >

a =

BT_Data: [1x66 struct]

→ length (a.BT_Data)

ans =

66

, , - "" .

( ).

+2

. , BT_Data 1 66, :

>> data(1).BT_Data

ans =

1x66 struct array with fields:
     Flags
     ...    %# etc.

, :

>> data(1).BT_Data

ans =

BT_Data: [1x66 struct]

, BT_Data 1 1 , BT_Data, 1 66. , , BT_Data ( 1 1). , :

>> size(data(1).BT_Data.BT_Data)

ans =

     1     66

, , :

fieldnames(data(1).BT_Data(1))

. , BT_Data - , - , , :

isstruct(data(1).BT_Data)

1, BT_Data .

+1

Source: https://habr.com/ru/post/1789866/


All Articles