RAP Logo

range

Map input values to different output ranges for data normalization and scaling.

range Block

The range block maps a numeric value to a different range.

Overview

The range block takes a numeric input value and maps it from a source range to a target range using linear interpolation. This is particularly useful for:

  • Data Normalization: Converting values to a standard range (e.g., 0-1, 0-100)
  • Unit Conversion: Converting between different measurement scales
  • Value Scaling: Adjusting values to fit specific requirements
  • Signal Processing: Normalizing sensor readings or signal values

Configuration Options

Input Range

  • From: The minimum value of the input range
  • To: The maximum value of the input range

Output Range

  • From: The minimum value of the output range
  • To: The maximum value of the output range

Clamping

  • Clamp: Whether to clamp output values to the output range
    • Enabled: Values outside the input range are clamped to the output range limits
    • Disabled: Values outside the input range are extrapolated beyond the output range

How It Works

The range block uses linear interpolation to map values:

output = (input - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin

Example 1: Temperature Conversion

Convert Celsius to Fahrenheit:

  • Input Range: 0 to 100 (Celsius)
  • Output Range: 32 to 212 (Fahrenheit)
  • Input: 25°C
  • Output: 77°F

Example 2: Percentage Normalization

Convert sensor readings to percentages:

  • Input Range: 0 to 1023 (analog sensor)
  • Output Range: 0 to 100 (percentage)
  • Input: 512
  • Output: 50%

Example 3: Score Scaling

Scale test scores to letter grades:

  • Input Range: 0 to 100 (raw score)
  • Output Range: 0 to 4 (GPA scale)
  • Input: 85
  • Output: 3.4

Use Cases

Data Preprocessing

Normalize data before machine learning processing:

Raw Data → range → Normalized Data → ML Model

Sensor Data Processing

Convert sensor readings to meaningful units:

Sensor Reading → range → Human-Readable Value

User Interface Scaling

Map data values to UI element properties:

Data Value → range → UI Position/Size

Audio/Video Processing

Normalize audio levels or video brightness:

Raw Signal → range → Normalized Signal

Tips

  • Choose Appropriate Ranges: Select input and output ranges that make sense for your data
  • Consider Clamping: Enable clamping if you want to limit output values to the specified range
  • Handle Edge Cases: Be aware of division by zero if input min equals input max
  • Test with Sample Data: Verify the mapping works correctly with your expected input values
  • Use with Other Blocks: Combine with math operations for complex transformations

Common Patterns

Normalization Chain

input → range (0-1) → processing → range (target range) → output

Multi-Stage Conversion

input → range (intermediate) → processing → range (final) → output

Conditional Scaling

input → switch → range (different ranges) → output
  • change - For simple property modifications
  • function - For complex mathematical operations
  • switch - For conditional range selection
  • template - For formatting scaled values