How to change particular element of a matrix by comparing with a scalar value?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
suchismita
am 7 Jul. 2014
Kommentiert: suchismita
am 7 Jul. 2014
i have a code and its not working:
a=rand(4,10);
b=round(a);
y=[1 3];
%only the y rows of a will be checking for condition
beta1=0.30;
if a<=beta1 %beta1 is less than equal a, b will change if its 1 will become 0 and viceversa
b(y,:)=~b(y,:);
end
its not happening...plz plz help me out...
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 7 Jul. 2014
try
a=rand(4,10);
b=round(a);
y=[1 3];
beta1=0.30;
c = b(y,:)
t = a(y,:) <= beta1;
c(t) = ~c(t);
b(y,:) = c;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!