 westerman111
		
			westerman111
		
		
		
		
		
		
		
		
	
			07-03-2013 08:04 AM - edited 07-03-2013 08:04 AM
I would like to change all Inf elements in my array to -1. Basically, I am looking for something similar to the range and coerce function, except that I want all values above a certain value to be a specific negative value, rather than go to that value.
I could use a case structure and go through each element in the array, but I am hoping to find something more efficient.Any ideas?
Solved! Go to Solution.
 crossrulz
		
			crossrulz
		
		
		 
		
		
		
		
		
	
			07-03-2013 08:34 AM
Let's clearify a little bit. You start by saying all Inf values. Then you say any values above a certain threshold. Which is it?
If you are just looking for Inf, then I would use a While Loop with a Search 1D Array to find the Inf value, use Replace Array Subset to change the value in the found index to -1. Stop the loop when the found index is -1 (not found).
If you want above a certain threshold, then you need a FOR loop to go through each element to check if it is above the threshold and then change the value.
 garrettmarsh
		
			garrettmarsh
		
		
		
		
		
		
		
		
	
			07-03-2013 08:48 AM
@crossrulz wrote:
...
If you want above a certain threshold, then you need a FOR loop to go through each element to check if it is above the threshold and then change the value.
If you go with this option, don't forget to use an In Place Element structure. Sounds like a perfect use case.
 Yamaeda
		
			Yamaeda
		
		
		
		
		
		
		
		
	
			07-03-2013 08:49 AM
@westerman111 wrote:
I would like to change all Inf elements in my array to -1. Basically, I am looking for something similar to the range and coerce function, except that I want all values above a certain value to be a specific negative value, rather than go to that value.
I could use a case structure and go through each element in the array, but I am hoping to find something more efficient.Any ideas?
You can loop through the array and use the in range and coerce, but only check the "coerced" output, and if True, then Replace array subset with your specific value.
/Y
 P@Anand
		
			P@Anand
		
		
		
		
		
		
		
		
	
			07-03-2013 08:54 AM
I would do that in this way.
If you want to check the values above a threshold just replace the "equal" with "greater or smaller" functions.
@Yamaeda wrote:
You can loop through the array and use the in range and coerce, but only check the "coerced" output, and if True, then Replace array subset with your specific value.
/Y
I don't understand this logic. sorry
07-03-2013 09:04 AM
Personally, I would do something close to this (note: I did not really try to optimise anything)...
 crossrulz
		
			crossrulz
		
		
		 
		
		
		
		
		
	
			07-03-2013 09:21 AM - edited 07-03-2013 09:22 AM
P@Anand wrote:
I would do that in this way.
Here's a simpler version...

 NitzZ
		
			NitzZ
		
		
		
		
		
		
		
		
	
			07-03-2013 09:21 AM
 P@Anand
		
			P@Anand
		
		
		
		
		
		
		
		
	
			07-03-2013 09:42 AM
@crossrulz wrote:
Here's a simpler version...
Agreed Architect but you didn't show the threshold logic. I would consider Don_Phillips's logic more simpler
 crossrulz
		
			crossrulz
		
		
		 
		
		
		
		
		
	
			07-03-2013 09:53 AM
P@Anand wrote:Agreed Architect but you didn't show the threshold logic. I would consider Don_Phillips's logic more simpler
Yours didn't have a threshold either. But I fully agree that Don's is the simplest. I'm curious what benchmarking would show...