【发布时间】:2011-07-17 16:32:38
【问题描述】:
假设我有一些转换操作,其中某些数量的矩阵 (M) 被相互替换(所有的都变成 5,所有的 2 变成 6,等等)。现在我知道我可以写这样的代码了:
if M(1,1)== 1 M(1,1)=5 end
if M (1,1)== 2 M(1,1)=6 end
if M(1,2)==1 M(1,2)=6 end
当然,如果我有(10×10×10)矩阵,这是很多不必要的工作。是否有可能定义 3 个维度(列、行、页)或告诉 matlab 类似:
% scan from point (1,1,1) to point (10,10,10) and apply mathematical operations when condition is fulfilled.
谢谢
【问题讨论】:
-
应该应用上一个问题中的相同解决方案(逻辑索引):stackoverflow.com/questions/6718543/…。我建议您阅读此索引指南:mathworks.com/help/techdoc/math/f1-85462.html
标签: matlab