|
try put the express on the left side of the "=", like following:
>> A=rand(5)*20
A =
5.5205 9.9673 15.0253 19.1858 16.8143
13.5941 19.1949 5.1019 10.9443 5.0856
13.1020 6.8077 10.1191 2.7725 16.2857
3.2522 11.7054 13.9815 2.9859 4.8705
2.3800 4.4762 17.8181 5.1502 18.5853
>> A(find(A(:,2)<=10), : )=0; % put express on the left side and value will be stalled in matrix according to your condition !
>> A
A =
0 0 0 0 0
13.5941 19.1949 5.1019 10.9443 5.0856
0 0 0 0 0
3.2522 11.7054 13.9815 2.9859 4.8705
0 0 0 0 0
>> A(find(A(:,2)>10), : )=1; % put express on the left side and value will be stalled in matrix according to your condition !
>> A
A =
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
Hope this is what you want :)
Good luck! |
评分
-
1
查看全部评分
-
|