Page 1 of 1

Write a function interpolate_and_plot (x_start, y_start, x_pts, int_pts, limit, func) which produces an interpolated plo

Posted: Thu Jun 02, 2022 7:52 am
by answerhappygod
Write A Function Interpolate And Plot X Start Y Start X Pts Int Pts Limit Func Which Produces An Interpolated Plo 1
Write A Function Interpolate And Plot X Start Y Start X Pts Int Pts Limit Func Which Produces An Interpolated Plo 1 (54.7 KiB) Viewed 29 times
CAN SOMEONE PLEASE FIX MY CODE. ANSWERS PROVIDED BY THE WEBSITE
KEEP ON BEING WRONG.
I HAVE UPLOADED SCREENSHOTS OF THE QUESTION, AN EXAMPLE
GRAPH, MY INCORRECT CODE AND THE ERROR FROM MY CODE.
Write a function interpolate_and_plot (x_start, y_start, x_pts, int_pts, limit, func) which produces an interpolated plot of values based on the input parameters: x_start: starting value for the sequence of x values y_start: starting value for the sequence of y values x_pts: number of initial points to generate • int_pts: number of points to interpolate • limit: upper limit of of x and y sequences func: function object we want to interpolate over Given an initial series of points (defined by parameters x_start, limit and x_pts), interpolate between them given the parameters (y_start, int_pts, limit, and func). Both initial and interpolated points should be evenly spaced. The function should return the pyplot object. Return a plot of the original points with marker style 'o' and a plot of the interpolated values with marker style 'x'. Below is an example for: interpolate_and_plot(0, 0, 10, 50, 2*np.pi, np.sin)

import numpy as np from scipy. interpolate import interpld from matplotlib import pyplot as plt def interpolate_and_plot(x_start, y_start, x_pts, int_pts, limit, func): """"produces graph!!!!! plt_ = plt plt_. figure() plt. figure(figsize=(10,7)) x=np. linspace(x_start, limit, num=x_pts) x_new-np. linspace(y_start, limit, num=int_pts) interpol_fn-interp1d (x, func(x)) plt.plot(x, func(x), 'o', x_new, interpol_fn (x_new), '-x') return plt_
***Error*** _tester Traceback (most recent call last): File " xal File " python3", line 82, in <module> main("output.png", "ans.png") tester diff = img1 python3", line 34, in main img2 ValueError: operands could not be broadcast together with shapes (700,1000,4) (480,640,4)