incI=zeros(length(featInd),length(tempInd));
for f = 1:length(featInd)
incI(f,:) = tempInd + featInd(f);
end
for k=1:length(featInd)
h([incI(k,:)]') = h([incI(k,:)]')+ 1;
end

2 comentarios

jgg
jgg el 26 de En. de 2016
You need to provide more information. What is h? What is featInd? What is tempInd? How are they structured?
Parag Patil
Parag Patil el 26 de En. de 2016
featInd=[1,24636] row vector
tempInd=[1,12332] row vector
h=[14593760,1] coloumn vector

Iniciar sesión para comentar.

 Respuesta aceptada

Honglei Chen
Honglei Chen el 26 de En. de 2016
Editada: Honglei Chen el 26 de En. de 2016

1 voto

Here is an example you can try
featInd = 1:24636;
tempInd = 1:12332;
incI = bsxfun(@plus,featInd(:),tempInd);
As to the second loop, I could be wrong but that looks just like a histogram for me, so you can probably do something like
[incU,~,incInd] = unique(incI(:),'stable');
h = zeros(14593760,1);
h(incU) = h(incU)+accumarray(incInd,ones(numel(incInd),1));

2 comentarios

Honglei Chen
Honglei Chen el 26 de En. de 2016
Updated the code with correct dimension, although the dimension of h may depend on what you have in featInd and tempInd
Parag Patil
Parag Patil el 27 de En. de 2016
Thanks Honglei Chen tried your approach for second loop. Works for smaller values of tempInd & featInd. For large values unique function gives out of memory error when executed on GPU.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 26 de En. de 2016

Comentada:

el 27 de En. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by