how to realize look up function in m script

3 views (last 30 days)
hello, i have x axle table and y axle table, when i set value within the range of x, how to get the output from y, may be some interpolation and curve smoothing should used. i hope it works in m script.
  8 Comments

Sign in to comment.

Accepted Answer

wenchao zhang
wenchao zhang on 5 Jul 2024
Edited: Walter Roberson on 5 Jul 2024
use interp1 seems ok,
x = 0:pi/4:2*pi;
v = sin(x);
xq = 0:pi/16:2*pi;
figure
vq2 = interp1(x,v,xq,'spline');
plot(x,v,'o',xq,vq2,':.');
xlim([0 2*pi]);
title('Spline Interpolation');

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!