Write a function that will receive data points in the form of x and y vectors. If the lengths of the vectors are not the same, then they can't represent data points, so an error message should be printed. Otherwise, the function will fit a polynomial of a random degree through the points and will plot the points and the resulting curve with a title specifying the degree of the polynomial. The degree of the polynomial must be less than the number of data points, n, so the function must generate a random integer in the range from 1 to n-1 for the polynomial degree.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question
100%

Matlab Question

Write a function that will receive data points in the form of x and y vectors.
If the lengths of the vectors are not the same, then they can't represent
data points, so an error message should be printed. Otherwise, the
function will fit a polynomial of a random degree through the points and
will plot the points and the resulting curve with a title specifying the
degree of the polynomial. The degree of the polynomial must be less than
the number of data points, n, so the function must generate a random
integer in the range from 1 to n-1 for the polynomial degree.
Transcribed Image Text:Write a function that will receive data points in the form of x and y vectors. If the lengths of the vectors are not the same, then they can't represent data points, so an error message should be printed. Otherwise, the function will fit a polynomial of a random degree through the points and will plot the points and the resulting curve with a title specifying the degree of the polynomial. The degree of the polynomial must be less than the number of data points, n, so the function must generate a random integer in the range from 1 to n-1 for the polynomial degree.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning