Ho to perform the same calculation in all columns of a matrix?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Max
 el 6 de Abr. de 2016
  
    
    
    
    
    Editada: Star Strider
      
      
 el 6 de Abr. de 2016
            Hi all,
I would like to perform "adtest" in all columns of my matrix sized 200x90 without having a loop iterating 90 times. I just wondered if there a way of getting a vector of 1x90 each value indicates the "adtest" of each column?
Thanks a lot in advance!
0 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 6 de Abr. de 2016
        
      Editada: Star Strider
      
      
 el 6 de Abr. de 2016
  
      This works:
D = randi(9, 15, 5);                                            % Create Data
Dc = mat2cell(D, size(D,1), ones(1,size(D,2)));                 % Split Into Cells By Column
adt = cellfun(@adtest, Dc);                                     % Perform ‘adtest’ On Each Cell Column
It takes advantage of MATLAB’s cell data type to ‘parse’ the input matrix into individual column cells, then uses cellful to perform adtest on each cell column. The result in ‘adt’ is a logical array of results.
EDIT — To get other results from adtest, add a variable to store them to the output of the cellfun call. So to get the significance as well, this works:
[adt,p] = cellfun(@adtest, Dc);                                 % Perform ‘adtest’ On Each Cell Column
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Multidimensional Arrays en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

