Discussion:
assign to infinite a value
shivax
2018-10-28 18:12:24 UTC
Permalink
hi
look that:
max=50;
min=-50;
newArr=[3 4 inf 7 3 2 5 6 inf -inf 9]

i want to assign to inf value max..and to -inf value -1 ==>[3 4 50 7 3 2 5
6 50 -50 9]

i try this:

isInf=find(isinf(newArr))

newArr2(isInf)=max;


but is not correct beacuse isinf(array) give me index of inf and -inf

can you write me other method? thank





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Richardson, Anthony
2018-10-28 18:42:30 UTC
Permalink
Subject: assign to infinite a value
hi
max=50;
min=-50;
newArr=[3 4 inf 7 3 2 5 6 inf -inf 9]
i want to assign to inf value max..and to -inf value -1 ==>[3 4 50 7 3 2 5
6 50 -50 9]
isInf=find(isinf(newArr))
newArr2(isInf)=max;
but is not correct beacuse isinf(array) give me index of inf and -inf
can you write me other method? thank
Try:
isInf=find(isinf(newArr) &newArr>0)

Tony
shivax
2018-10-29 08:30:41 UTC
Permalink
Correct! thank you



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Loading...