Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help doing linear interpolation using java in the following code. The fun

ID: 644513 • Letter: I

Question

I need help doing linear interpolation using java in the following code. The function just takes in on parameter, that is a list of arrays. each array in the list contains 3 elements for X,Y,Z data points.

Right now this code just multiplies all the values in the list by 2. I want to now add the average value of 2 points in between those to points. i imagine the easiest way to do this is to

1) caluclate the average of the the points in an array

2) Store that calculation in a temp array

3) than insert that array into the list of arrays inbetween the 2 array you used to get the average.

Code Below---------------------------------------------------------------

package sysnetlab.android.sdc.replay.metamorphic;

import java.util.List;


public class BaseLineShift {

    public List transform(List inputData)
    {

        for(int i=0; i             float[] array = inputData.get(i);

            for(int j =0;j                 array[j] = array[j] *2;


            }
            inputData.set(i, array);
        }
        return inputData;


    }
}

I need help doing linear interpolation using java in the following code. The function just takes in on parameter, that is a list of arrays. each array in the list contains 3 elements for X,Y,Z data points. Right now this code just multiplies all the values in the list by 2. I want to now add the average value of 2 points in between those to points. i imagine the easiest way to do this is to 1) caluclate the average of the the points in an array 2) Store that calculation in a temp array 3) than insert that array into the list of arrays inbetween the 2 array you used to get the average. Code Below--------------------------------------------------------------- package sysnetlab.android.sdc.replay.metamorphic; import java.util.List;

Explanation / Answer

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class StepServiceTest {
  
   public static List<float []> transform(List<float []> inputData){
       for(int i = 0; i < inputData.size() - 1; ++i){
           float[] array1 = inputData.get(i);
           float[] array2 = inputData.get(i + 1);
           float[] array3 = new float[array1.length];
           for(int j = 0; j < array1.length; ++j){
               array3[j] = (array1[j] + array2[j]) / 2;
           }
           inputData.add(i + 1, array3);
           i += 1;
       }
        return inputData;
   }
  
   public static void main(String args[]){
       List<float []> inputData = new ArrayList<float []>();
       float arr[] = {3, 8, 4};
       inputData.add(arr);
       float arr1[] = {4, 2, 8};
       inputData.add(arr1);
       float arr2[] = {7, 9, 3};
       inputData.add(arr2);
       float arr3[] = {2, 6, 4};
       inputData.add(arr3);
       transform(inputData);
       for(int i = 0; i < inputData.size(); ++i){
           for(int j = 0; j < inputData.get(i).length; ++j){
               System.out.print(inputData.get(i)[j] + " ");
           }
           System.out.println();
       }
       System.out.println();
   }      
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote