Say I define that a and b are 3 and 4, respectively. I heva a matrix M that I want to swap all instances of a with b. How would I do that? I tried doing
res = M(M==a) = b;
it works if I don't have the res there but I need the res there to output my result for this specific issue. It keeps telling me it needs to be
res = M(M==a) == b; but that only gives me the 2x1 logical array that has 0 0 in it
댓글 수: 2
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/630829-replacing-all-values-of-a-with-b-in-a-matrix#comment_1096514
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/630829-replacing-all-values-of-a-with-b-in-a-matrix#comment_1096514
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/630829-replacing-all-values-of-a-with-b-in-a-matrix#comment_1096519
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/630829-replacing-all-values-of-a-with-b-in-a-matrix#comment_1096519
댓글을 달려면 로그인하십시오.