Q:

Write a function mirror that will receive one input vector consisting of y coordinates of data points. The function will fit a second order polynomial through the points

0

 Write a function mirror that will receive one input vector consisting of y coordinates of data points. The function will fit a second order polynomial through the points. The function will plot, on one graph, the original data points (using green *s), the curve (using blue and with enough points so that it is very smooth) and also “mirror image” points (in red *s). The “mirror image” points are, for every x coordinate, equidistant from the curve as the original data point. So, if the original data point is 2 above the curve, the mirror image point will be 2 below it. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

mirror.m

function mirror(y)

x = 1:length(y);

p = polyfit(x,y,2);

longx = 1:0.1:length(x);

curve = polyval(p, longx);

ests = polyval(p,x);

oppests = ests + (ests - y);

plot(x,y,'g*',longx,curve,x,oppests,'r*')

end

Data on the flow of water in rivers and streams is of great interest to 

civil engineers, who design bridges, and to environmental engineers, 

who are concerned with the environmental impact of catastrophic 

events such as flooding.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now