help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: change element min in matrix


From: Przemek Klosowski
Subject: Re: change element min in matrix
Date: Thu, 14 Nov 2019 15:26:50 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 11/14/19 11:46 AM, shivax via Help list for GNU Octave wrote:
look this example:

g=[4 5 6;1 2 3;9 4 5]

i want to find minimun for each rows and change it with zero

min(g,[],2)

ans  F: 4 1 4

now i change min value in matrix:

g=[0 5 6;0 2 3;9 0 5]

to do it i code :

for i=1:length(F)
    idx=(find(g(:,i)==F(i))
   g(idx,i)=0;
endfor

but it's possible to avoid loop? thank you

m=min(g')'

g(g==repmat(m,1,size(g)(2)))=0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]