Filter löschen
Filter löschen

A problem containing Interpolation

1 Ansicht (letzte 30 Tage)
George Rodriguez
George Rodriguez am 6 Dez. 2020
Kommentiert: Stephen23 am 7 Dez. 2020
x= Generate 6 equally spaced data points x, which starts from 1 and ends at 15.
y = 2 x 3
x2= Generate 40 equally spaced data points x2, which starts from 1 and ends at 15.
y2=Use linear interpolation to find theintermediate function values (y2) for x2 and generate a plot showing data pairs (x1, y1) as well as (x2, y2). In the plot, please title, label, legend and use color style appropriately.
CODE:
x=1:15:6;
y=2*x-3*randn(1:15:6);
x2=1:15:40;
y2=interp1(x,y,x2,'linear');
plot(x,y,'rx',x2,y2,'bo');
legend('original data','interpolation data');

Antworten (1)

Setsuna Yuuki.
Setsuna Yuuki. am 7 Dez. 2020
You must change:
x=linspace(1,15,6); %%This line 6 equally spaced data points
y=2*x-3*randn(1,length(x)); %%This line
x2=linspace(1,15,40); %%This line Generate 40 equally spaced data points
y2=interp1(x,y,x2,'linear');
plot(x,y,'rx',x2,y2,'bo');
legend('original data','interpolation data');
title('Titulo uwu')

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by