필터 지우기
필터 지우기

Similar code as vec2ind function for MATLAB coder?

조회 수: 1 (최근 30일)
HASAN AL-KAF
HASAN AL-KAF 2021년 10월 16일
Hi
I want a code that give similar function as vec2ind.
I found this code sum( repmat((1:size(vec,1)).', 1, size(vec,2)) .* vec)
but this 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( repmat((1:size(vec,1)).', 1, size(vec,2)) .* vec) is 50.
How can get exactly same result?. I want to transfer This matlab code to c++.
Thank you.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by