在MATLAB中将矩阵位置乘以标量

时间:2018-05-30 23:38:51

标签: matlab

我的matlab代码遇到了一个小问题,因为我试图将单个单元格位置乘以常量标量值以用于显示目的。

** A是随机十进制数的150x150矩阵

hLocalMax = vision.LocalMaximaFinder;
hLocalMax.MaximumNumLocalMaxima = 22500;
hLocalMax.NeighborhoodSize = [3 3];
hLocalMax.Threshold = 0;
location = step(hLocalMax, A);

new_location = unique(location,'rows');
new_location = new_location.*0.1;

disp(new_location)

现在,我的答案是四舍五入到最接近的int值

1 个答案:

答案 0 :(得分:0)

我无法确切地说出你所引用的内容,但我认为你说new_location是一个int,你希望它是一个双重的。这是一些样本。

A =randn(150);
hLocalMax = vision.LocalMaximaFinder;
hLocalMax.MaximumNumLocalMaxima = 22500;
hLocalMax.NeighborhoodSize = [3 3];
hLocalMax.Threshold = 0;
location = step(hLocalMax, A);

new_location = double(unique(location,'rows'));
new_location = new_location.*0.1;

disp(new_location)
0.1000    0.1000
0.1000    0.2000
0.1000    0.6000
0.1000    0.8000
0.1000    1.0000
0.1000    1.4000
0.1000    1.6000
0.1000    1.8000
0.1000    2.1000
0.1000    2.3000
0.1000    2.6000
0.1000    3.3000
0.1000    3.7000
0.1000    5.3000
0.1000    5.6000
0.1000    5.9000
0.1000    6.2000
0.1000    6.5000
0.1000    7.5000
0.1000    8.2000