How to apply function on columns while skipping certain columns
Mostrar comentarios más antiguos
So I have a matrix that has 31413 rows and 950 columns. I want to apply a function starting from column 2 till column 10, skipping column 11, then applying the same function from coumn 12 till column 20, then skipping column 21 and applying the function on column 22 till column 30 and so on.
Basically something like this
[col1 col2...col10 col11 col12...col20 col21 col22...col30 and so on until column 950]
(the columns in between are where I want to apply the function basically)
Is there any way I can do this? Any help appreciated!!!
2 comentarios
James Tursa
el 19 de Mzo. de 2020
What is the function?
Zuha Yousuf
el 19 de Mzo. de 2020
Respuesta aceptada
Más respuestas (1)
Mohammad Sami
el 19 de Mzo. de 2020
m = rand(31413,950);
allcols = 1:950;
exccols = 1:10:950;
applcols = allcols(~ismember(allcols,exccols));
out = max(m(:,applcols)); % some builtin functions can be used directly
% or
out = arrayfun(@(x)max(m(:,x)),applcols);
2 comentarios
Zuha Yousuf
el 19 de Mzo. de 2020
Zuha Yousuf
el 19 de Mzo. de 2020
Editada: Zuha Yousuf
el 19 de Mzo. de 2020
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!