blank  

Next Post:

All The Aspects Of Plastic Injection Molding Processes

Performing Interpolations In MatLab

blank

In calculus, interpolations are a very important tool. If you do not know about the corresponding value of an interval value inside the set of data, interpolation is a very powerful tool. In calculus, there are different methods of interpolations available. Also in engineering, interpolations are generally used.

Matlab provides a bunch of commands that you can make interpolations inside the set of data. What you need to do is, you need to define your data in Matlab in the proper way. And you can make interpolations about this data set by using the ‘interp1()’ and ‘spline()’ command in Matlab.

Here we explain how to use ‘interpl()’ and ‘spline()’ commands in Matlab to make interpolations, with very basic examples below.

How To Use ‘interp1()’ Command In MatLab?

Take look at the very basic example below that is executed in the Matlab command window to understand the use of the interp1() command in Matlab.

>> a = 0:0.3:3;
b = [0 5 6 7 8 9 11 23 26 30 35];
x = interp1(a, b, 1.6)

x =

    9.6667

>> 

As you see in the example above, we defined two vectors ‘a’ and ‘b’ respectively. We will use ‘a’ as input values of data and ‘b’ as output values. We want to find the corresponding value of ‘a’ inside ‘b’, which is not defined in a ‘a’. So in this way, we can use interp1() command.

The first vector or data set must be defined in an ascending way to make interpolation inside it.

What we did is, we typed ‘a’ and ‘b’ inside interp1() command. Then we typed the value at last, which we want to find out inside ‘a’. It must be the intermediate value between elements of vector ‘a’.

Download And Install MatLab 2020!

In answer, you can see the corresponding result for the value of 1.6 in ‘a’.

How To Use ‘spline()’ Command In MatLab?

Also, you can make non-linear interpolations in Matlab easily. To do it, you need to use the ‘spline()’ command. Take a look at the example below to understand the use of the ‘spline()’ command in Matlab.

>> a = 0:0.3:3;
b = [0 5 6 7 8 9 11 23 26 30 35];
x = spline(a, b, 1.6)

x =

    8.8754

The same vectors are used again in this example. The use of the ‘spline()’ command is also the same as the interp1() command. spline() uses the cubic spline interpolation method to find the corresponding values.

As you see above, the answers are different for spline() and interp1() commands.

YOU CAN LEARN MatLab IN MECHANICAL BASE; Click And Start To Learn MatLab!

Conclusion

This is the most basic explanation of interpolation operation in Matlab. If you want further examples about making interpolations in Matlab, inform us in the comments below.

Do not forget to leave your comments and questions below about the use of base conversion commands in Matlab below. 

This article is prepared for completely educative and informative purposes.

Your precious feedbacks are very important to us.

  • Site Comments

At least 10 characters required.