Matlab interp1 function x-points for given y-points
1 view (last 30 days)
Show older comments
Dear Community Members,
Hopefully this finds you safe and well. Using interp1 to acquire x-points for given y-points does not seem to work. Data in this particular instance generated via a function however in reality it is experimental data.
%**main function
x=[3:0.1:6];
y=sin(x);
%***y-array for new x-values
y_array = [-0.9:0.005:0.1];
x_new = interp1(y,x,y_array);
figure
plot(x,y,'k+-',x_new,y_array,'rx-')
grid on
Resutant image see attachment.
Any help on how to extrapolate between current and next data opints would be appreciated.
0 Comments
Accepted Answer
Ameer Hamza
on 8 Oct 2020
Inverting nonlinear function using interp1() like this is not correct. Check the following code
%**main function
x=[3:0.1:6];
y=sin(x);
%***y-array for new x-values
y_array = -0.9:0.005:0.1;
interp_x = @(xq) interp1(x, y, xq);
x_new = fsolve(@(xq) interp_x(xq) - y_array, 3+rand(size(y_array)));
figure
plot(x,y,'k+-',x_new,y_array,'rx-')
grid on
4 Comments
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots 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!