HenrikBengtsson/R.matlab

Structure Field/Value mismatch when importing in R

Nodragem opened this issue · 0 comments

Hello,
I have this code in MATLAB:

for row = 1:size(sim_values, 1) % we run only 1 simulation of 100 iterations/trials here
    disp('Current Simulation:  '); disp(sim_values{row, :});
    tic
    % run the simulation 100 times:
    [targ_RTs, dist_RTs, rall, uall]= runDinasaur2(sim_values(row,:));
    disp('time of simulation')
    toc

    tic
    results(row).keys = sim_keys;
    results(row).values = sim_values(row,:);
    results(row).target_RTs = targ_RTs;
    results(row).distractor_RTs = dist_RTs;
    results(row).firing_rate = rall;
    results(row).membrane_potential = uall;
    save('./results/distances/results_distance.mat', 'results')
    disp('time saving data')
    toc

end

That generates this:
screenshot from 2016-12-05 16-31-29

However, when I am in R and run this code:

setwd("/home/c1248317/Bitbucket/Dinasaur/results")
library(R.matlab)
r <- readMat("distances/results_distance.mat")
r$results

I obtain:

, , 1

                   [,1]           
keys               List,8         
values             List,1         
target.RTs         Integer,6      
distractor.RTs     Numeric,5      
firing.rate        Numeric,5      
membrane.potential Numeric,1200000

, , 2

                   [,1]           
keys               Numeric,1200000
values             List,8         
target.RTs         List,1         
distractor.RTs     Integer,6      
firing.rate        Numeric,5      
membrane.potential Numeric,5      

, , 3

                   [,1]           
keys               Numeric,1200000
values             Numeric,1200000
target.RTs         List,8         
distractor.RTs     List,1         
firing.rate        Integer,6      
membrane.potential Numeric,5      

, , 4

                   [,1]           
keys               Numeric,5      
values             Numeric,1200000
target.RTs         Numeric,1200000
distractor.RTs     List,8         
firing.rate        List,1         
membrane.potential Integer,6      

, , 5

                   [,1]           
keys               Numeric,5      
values             Numeric,5      
target.RTs         Numeric,1200000
distractor.RTs     Numeric,1200000
firing.rate        List,8         
membrane.potential List,1         

, , 6

                   [,1]           
keys               Integer,6      
values             Numeric,5      
target.RTs         Numeric,5      
distractor.RTs     Numeric,1200000
firing.rate        Numeric,1200000
membrane.potential List,8         

, , 7

                   [,1]           
keys               List,1         
values             Integer,6      
target.RTs         Numeric,5      
distractor.RTs     Numeric,5      
firing.rate        Numeric,1200000
membrane.potential Numeric,1200000

, , 8

                   [,1]           
keys               List,8         
values             List,1         
target.RTs         Integer,6      
distractor.RTs     Numeric,5      
firing.rate        Numeric,5      
membrane.potential Numeric,1200000


and

> summary(r$results)
      Length  Class  Mode   
 [1,]       8 -none- list   
 [2,]       1 -none- list   
 [3,]       6 -none- numeric
 [4,]       5 -none- numeric
 [5,]       5 -none- numeric
 [6,] 1200000 -none- numeric
 [7,] 1200000 -none- numeric
 [8,]       8 -none- list   
 [9,]       1 -none- list   
[10,]       6 -none- numeric
[11,]       5 -none- numeric
[12,]       5 -none- numeric
[13,] 1200000 -none- numeric
[14,] 1200000 -none- numeric
[15,]       8 -none- list   
[16,]       1 -none- list   
[17,]       6 -none- numeric
[18,]       5 -none- numeric
[19,]       5 -none- numeric
[20,] 1200000 -none- numeric
[21,] 1200000 -none- numeric
[22,]       8 -none- list   
[23,]       1 -none- list   
[24,]       6 -none- numeric
[25,]       5 -none- numeric
[26,]       5 -none- numeric
[27,] 1200000 -none- numeric
[28,] 1200000 -none- numeric
[29,]       8 -none- list   
[30,]       1 -none- list   
[31,]       6 -none- numeric
[32,]       5 -none- numeric
[33,]       5 -none- numeric
[34,] 1200000 -none- numeric
[35,] 1200000 -none- numeric
[36,]       8 -none- list   
[37,]       1 -none- list   
[38,]       6 -none- numeric
[39,]       5 -none- numeric
[40,]       5 -none- numeric
[41,] 1200000 -none- numeric
[42,] 1200000 -none- numeric
[43,]       8 -none- list   
[44,]       1 -none- list   
[45,]       6 -none- numeric
[46,]       5 -none- numeric
[47,]       5 -none- numeric
[48,] 1200000 -none- numeric

So it seems that the last array (that should be [49,]) is not loaded.
Then the data are not attributed to the good fields.

Any idea of what is happening?