只是在使用 MATLAB 将矩阵的所有值除以标量时遇到一些问题。
我的代码看起来像,
ncol = length(indpic(1,:)); % ncol = 32
row0 = sum(indpic == 0,2); % 161 * 1 matrix
rowprob0 = 'row0' / 'ncol';
但最后一行一直导致错误。我尝试了以下方法,但它们都没有工作,
rowprob0 = 'row0' ./ 'ncol';
rowprob0 = 'row0' * (1/('ncol'))';
rowprob0 = 'row0' .* (1/('ncol'))';
我也尝试过解决这个问题,但效果更差,
ncol = length(indpic(1,:)); % ncol = 32
row0 = sum(indpic == 0,2); % 161 * 1 matrix
id_ncol_1 = eye(ncol,ncol);
id_ncol = (id_ncol_1).*(ncol);
rowprob0 = 'row0' / 'id_ncol';
如果有人可以帮助我,那将不胜感激:) 提前欢呼