Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Say that the original values are in the array signal. Compute the smoothed array by doing this: Each value smooth[N] is the average of three
Say that the original values are in the array "signal". Compute the smoothed array by doing this: Each value smooth[N] is the average of three values: signal[N-1], signal[N], and signal[N+1].
For the first element of smooth, average the first two elements of signal. For the last element of smooth, average the last two elements of signal.
Use integer arithmetic for this so that the values in smooth are integers.
import java.io.* ; class Smooth { public static void main ( String[] args ) { int[] signal = {5, 5, 4, 5, 6, 6, 7, 6, 5, 4, 1, 4}; int[] smooth // compute the smoothed value for each // cell of the array smooth smooth[0] = smooth[ signal.length-1 ] = for ( ) { } // write out the input for ( int j=0; j < smooth.length; j++) { } // write out the result for ( int j=0; j < smooth.length; j++) { } } }
In interpreting the results, remember that integer division discards the remainder. It does not compute a rounded value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started