vec2ind is not supported for code generation?

4 visualizaciones (últimos 30 días)
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah el 23 de Nov. de 2016
Comentada: HASAN AL-KAF el 16 de Oct. de 2021
vec2ind is not supported for code generation. Is there any other way to solve this issue?

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Nov. de 2016
In R2016b notation,
sum((1:size(vec,1)).' .* vec)
In earlier releases you would need
sum( repmat((1:size(vec,1)).', 1, size(vec,2)) .* vec)
  2 comentarios
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah el 24 de Nov. de 2016
Thanks for your answer
HASAN AL-KAF
HASAN AL-KAF el 16 de Oct. de 2021
Hi
The code doesn't give same result as vec2ind
for example vec= [1;0;1;0;1;1;5;0]
The result of vec2ind is 7.
The result of sum((1:size(vec,1)).' .* vec) is 50.
How can get exactly same result?. Becaue I want to transfer matlab code to c++.
Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox 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!

Translated by