vec2ind is not supported for code generation?
2 次查看(过去 30 天)
显示 更早的评论
vec2ind is not supported for code generation. Is there any other way to solve this issue?
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!