# How can I make a function that calculates the values of the linear interpolation ?

3 Ansichten (letzte 30 Tage)
Ihor am 4 Dez. 2022
Bearbeitet: Torsten am 9 Dez. 2022
How can I make a function that calculates the values of the linear interpolation function f(x) = a.x + b for an interval of x values given by Xl = [xmin,xmax] where n >= 1 is the number of intervals into which the interval Xl will be divided?
##### 1 KommentarKeine anzeigenKeine ausblenden
Walter Roberson am 4 Dez. 2022
linspace()

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Gokul Nath S J am 9 Dez. 2022
Hi Ihor,
As per my understanding, if given minimum and maximum values of x, you are interested in finding the linear interpolation. Please find the following function code for your reference,
function interpolated_values = linear_interpolation(xmin, xmax, a, b)
N = 1000;
x = linspace(xmin, xmax, N);
interpolated_values = a*x + b;
end
Also, the value of a and b are customizable and can be defined inside the function. I assumed the number of points to be 1000.
Hope this helps!
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Interpolation in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!