Question: In matlab Obtain a piecewise linear interpolation of the function f(x) = ex/a sin(x2 +b) where a is the rst digit of your SUID and

In matlab

Obtain a piecewise linear interpolation of the function f(x) = ex/a sin(x2 +b) where a is the rst digit of your SUID and b is its last digit. Interpolation should take place on the interval [0,7]. Try equally spaced nodes with distance h = 1, h = 0.5, until you nd one that works reasonably well. Report the spacing h you found suitable in a comment.

Method: To begin with, dene a function f (function handle would work). Calculate the nodes, the values of f at nodes, and the slopes of interpolating segments (the vector slope below; you may refer to the function pwL). Then evaluate the interpolant.

One approach is this: t = linspace (0 ,7 ,100);

pl = zeros ( size ( t ));

for i = 1: length ( t ) i f t ( i ) == x(1) pl ( i ) = y(1) + slope (1) ( t ( i ) x(1) );

else id = sum(x

pl ( i ) = y( id ) + slope ( id ) ( t ( i ) x( id ) );

end end Finally, plot both f and the interpolant together for comparison, using dierent colors.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!