assign to infinite a value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

assign to infinite a value

shivax
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


Reply | Threaded
Open this post in threaded view
|

RE: assign to infinite a value

Tony Richardson
> To: [hidden email]
> Subject: assign to infinite a value
>
> 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

Try:
        isInf=find(isinf(newArr) &newArr>0)

Tony




Reply | Threaded
Open this post in threaded view
|

RE: assign to infinite a value

shivax