Write a function that will take a dataset (x,y), a best fit model (model), and the upper and lower prediction bounds (lb,ub) for the model and produces a plot exactly like the one above. Your function should return the figure handle as output.
To run the function, use these variables for x, y, model, lb, and ub.
x = 0:10;
y = [1.08459242882334 15.6947129993263 14.2386103675462 6.42746590257512 31.1493692505068 28.3500898661844 36.6199801626288 32.7960413139854 48.8539622750404 40.0146245913800 53.5578609728933];
model = [14.5329684874318 15.1878864648738 16.5582980455985 18.6442032296059 21.4456020168959 24.9624944074686 29.1948804013239 34.1427599984619 39.8061331988826 46.1850000025860 53.2793604095720];
lb = [8.0385 9.3470 10.9611 13.0581 15.7997 19.2858 23.5490 28.5567 34.2089 40.3441 46.7849];
ub = [21.0274 21.0287 22.1555 24.2303 27.0915 30.6392 34.8408 39.7288 45.4033 52.0259 59.7738];
Solution Stats
Problem Comments
8 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers276
Suggested Problems
-
426 Solvers
-
Electrical Diode Current Calculation
1093 Solvers
-
Number of Even Elements in Fibonacci Sequence
1633 Solvers
-
317 Solvers
-
Split Even Number Into Two Primes
211 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
There's seems to be an incorrect value for plot color of Data values.
Thanks, Dyuman. I've updated it - hopefully I've *corrected* it :)
Is it me being colorblind or there is still a problem with the color of Data values?
Yes, the test for color values seems incorrect for me as well.
I have the plot recreated, but the assertions don't seem to call the created function. Am I missing something?
@luxintenebris It's possible for a test suite to include code before the first test; this is run when a solution is evaluated, but isn't shown as part of the tests.
@Christian Schröder In that case, should there be some check that it always runs? Or just include it in the suite? I had to call the function in the scratchpad first before the assertions could be properly handled.
@luxintenebris The "hidden" code should always run since it's part of the test suite as far as the Cody engine is concerned, even if it's not shown on the web frontend.
And yes, this can be annoying because you then can't simply copy tests to the scratchpad to check your solution before submitting. At least in this problem, the hidden code doesn't do anything beyond setting the same variables given in the problem description, and calling the function.
That said when you submit your solution using the scratchpad should never be necessary, hidden test suite code or not.