Loading the excel file(cell array contains elements of different dimension) in MATLAB
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    surendra kumar Aralapura mariyappa
 il 27 Giu 2019
  
    
    
    
    
    Commentato: surendra kumar Aralapura mariyappa
 il 27 Giu 2019
            Hey all, 
I have an excel file, I need to load this excel file in MATLAB, but it is showing NaN for the position where a matrix is built.
Here is an example:
 A = xlsread('Area_Matrix.xlsx');
A =
     0   NaN     0     0     0     0    23
   NaN     0    47     0     0     0    18
But here NaN should be a matrix like below;
[0 0 ; 0 23];
It is like building a cell array in excel to have a matrix of different dimensions.
I need to get the cell array from excel like below: 
A = {   0       [ 0 4749.50  ;0 2375.80]        0         0          0          0         [0 0; 0 2375.8 ] ;
       [ 0 4749.50  ;0 2375.80 ]       0         [0 0; 0 2375.8 ]   4749.50      0          0          [0 0; 0 1835.80  ];
        0       [ 0 0 ; 0 2375.80]       0          0         0          0            0;
        0         4749.50       0          0       2375.80    4749.50       [0 0; 0 1835.80  ];
        0          0            0       2375.80      0          0            0;
        0          0            0       4749.50       0         0             [0 0; 0 2375.8 ] ;
     [0 0; 0 2375.8 ]      [0 0; 0 1835.80  ]      0      [0 0; 0 1835.80  ]      0      [0 0; 0 2375.8 ]             0};
So I am planning to use excel to enter the data and load it later in MATLAB.
Any suggestions and answers would be most welcomed
Thanks in advance.
0 Commenti
Risposta accettata
  Alex Mcaulley
      
 il 27 Giu 2019
        Try this:
[num,~,A] = xlsread('Area_Matrix.xlsx');
A(isnan(num)) = cellfun(@str2num,A(isnan(num)),'uni',0); %A is the cell array you want 
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Spreadsheets in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

