MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   用该列的值替换所有列中的值 (https://www.labfans.com/bbs/showthread.php?t=26734)

poster 2019-12-14 20:46

用该列的值替换所有列中的值
 
如何用该列号替换ALL列中的所有1?我已经可以逐列进行操作:

output(output(:,3)== 1,3)= 3;
output(output(:,4)== 1,4)= 4;
output(output(:,5)== 1,5)= 5;
等等...

但是我觉得自己像傻瓜一样写每一栏。应该有一种方法可以一次全部完成吗?



[B]回答:[/B]

您可以为此使用[URL="http://www.mathworks.com/help/techdoc/ref/find.html"]FIND[/URL] :

[rowIdx,colIdx] = find(output==1); output(output==1) = colIdx;

[url=https://stackoverflow.com/questions/5460956]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:36

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.