plot a continuous function using sine, cosine, log, exp, quadratic function that will go from 0,0 to 2,6 to 13,-4 in matlab

Here is a solution that uses a combination of sine, cosine, and quadratic functions to create a smooth curve that passes through the specified points:

main.m
% Define the x-values of the points
x = [0, 2, 13];

% Define the y-values of the points
y = [0, 6, -4];

% Define a range of x-values for the curve
xrange = linspace(0, 13);

% Create the curve with a combination of functions
curve = 2*sin(xrange) - 3*cos(xrange - 1) + 4*log(xrange + 1) + 1/2*(xrange - 2).^2;

% Plot the curve and the points
plot(xrange, curve)
hold on
plot(x, y, 'o')
389 chars
17 lines

Output: Matlab Plot

Note that the choice of functions used to create the curve is somewhat arbitrary, and other combinations of functions could be used to obtain different shapes.

related categories

gistlibby LogSnag