MATLAB 帮助中心
本页采用了机器翻译。点击此处可查看英文原文。
替换数组中的值
B = changem(A,new)
B = changem(A,new,old)
B = changem(A,new) 将数组 A 中所有出现的 0 替换为指定的标量 new。此函数适用于替换分类网格中的值。
B
A
new
0
B = changem(A,new,old) 将所有出现的 old 替换为 new。
old
示例
全部折叠
读取夏威夷欧胡岛的土地覆盖分类数据,包括数组、地图单元参考对象和颜色图。数组元素用于索引颜色图。
[A,R,cmap] = readgeoraster("oahu_landcover.img");
落叶林、常绿林和混交林在数组中分别由值 9、10 和 11 表示。创建一个数组,将所有森林的颜色统一为相同颜色,方法是将所有出现的 9 和 10 替换为 11。
9
10
11
new = [11 11]; old = [9 10]; B = changem(A,new,old);
显示新旧土地覆盖分类。
figure mapshow(A,cmap,R) title("Land Cover Classification with Three Forest Types")
figure mapshow(B,cmap,R) title("Land Cover Classification with One Forest Type")
输入数组。
新值,指定为标量或向量。当 new 和 old 是向量时,该函数将 old(k) 的所有出现位置替换为 new(k)。
old(k)
new(k)
new 的大小必须与 old 的大小相匹配。
替换值,指定为标量或向量。当 new 和 old 是向量时,该函数将 old(k) 的所有出现位置替换为 new(k)。
在 R2006a 之前推出
replace
fillmissing
readgeoraster
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处