[英]conversion between Matlab and C++
I have difficulties while converting the following matlab line into C++: 将以下matlab行转换为C ++时遇到困难:
for i=1:height
for j=1:width
if (match == 0)
[min_w, min_w_index] = min(w(i,j,:));
mean(i,j,min_w_index) = double(data(i,j));
sd(i,j,min_w_index) = sd_init;
end
rank = w(i,j,:)./sd(i,j,:);
rank_ind = [1:1:C];
end
end
Especially I don't know how to covert the "min_w_index" part. 特别是我不知道如何隐藏“ min_w_index”部分。 Could someone help me on this point? 在这一点上有人可以帮我吗?
Most common solution for min function in such case is 在这种情况下,最小功能的最常见解决方案是
int min_w = w[i][j][0];
int min_w_index = 0;
for (k = 1; k < maxk; k++)
if (w[i][j][k] < min_w)
{
min_w = w[i][j][k];
min_w_index = k;
}
Don't forget that C++ has zero-based index, but Matlab one-based. 不要忘记C ++具有从零开始的索引,但是Matlab是从零开始的。 I already see problem in your comment. 我已经在您的评论中看到了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.