vec2ind is not supported for code generation?

조회 수: 2 (최근 30일)
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2016년 11월 23일
댓글: HASAN AL-KAF 2021년 10월 16일
vec2ind is not supported for code generation. Is there any other way to solve this issue?

채택된 답변

Walter Roberson
Walter Roberson 2016년 11월 23일
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
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2016년 11월 24일
Thanks for your answer
HASAN AL-KAF
HASAN AL-KAF 2021년 10월 16일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by