How to make the condition for checking the matrix value ?

조회 수: 1(최근 30일)
function [popnew1,mutated] =mutation(A,Pm)
mutated = find(rand(size(A))<Pm);
popnew1 = A;
% Why my this condition is not working
if A(mutated)== 1
popnew1(mutated) = 2-A(mutated);
popnew1(mutated) = 1-A(mutated);
Please Help me why my this condition part is not working Where A is 3x8 matrix and Pm=0.1 .
Where is the problem in my condition ?

채택된 답변

VBBV 2022년 11월 26일
popnew1 = 2-A(mutated);
  댓글 수: 10
Akash Pal
Akash Pal 2022년 11월 28일
Thank you for your suggestion .

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by