- https://www.mathworks.com/help/deeplearning/ref/regression.html
- https://www.mathworks.com/help/deeplearning/index.html
- https://www.mathworks.com/products/deep-learning.html
what toolbox to include for regression
3 views (last 30 days)
Show older comments
I am running the following code on MATLAB Grader
A=[13 16 19 21 24 26 28]
M=[13 20 23 31 36 42 48]
[r,m,b] =regression(A,M)
It is throwing the following error.
"Undefined function 'regression' for input arguments of type 'double'."
What toolbox I need to include to over come this error?
0 Comments
Accepted Answer
Shivani
on 11 Jun 2024
Edited: Shivani
on 11 Jun 2024
The regression function is a part of the Deep Learning Toolbox. The following links can be used to access the associated MATLAB documentation.
However, please note that it is not recommended to use the 'regression' function. Instead, it is recommended to use the 'fitlm' function from the Statistics and Machine Learning Toolbox to fit a linear regression model. Please access the following links for more information:
0 Comments
More Answers (1)
Image Analyst
on 11 Jun 2024
For these few data points, and for a case like this where the best fit might simply be a line, you can use the build-in polyfit and polyval functions. Here is some code for you:
A=[13 16 19 21 24 26 28];
M=[13 20 23 31 36 42 48];
plot(A, M, 'b.-', 'MarkerSize', 30); % Plot original data in blue.
grid on;
coefficients1 = polyfit(A, M, 1) % Fit a line.
coefficients2 = polyfit(A, M, 2) % Fit a quadratic.
% Place a line along the fitted formula
x = linspace(min(A), max(A), 1000);
% Plot the fitted line.
y1 = polyval(coefficients1, x);
hold on;
plot(x, y1, 'r-', 'LineWidth', 2); % Plot linear fit as a red curve.
% Plot the fitted quadratic.
y2 = polyval(coefficients2, x);
plot(x, y2, 'm-', 'LineWidth', 2); % Plot quadratic fit as a magenta curve.
legend('Original Data', 'Fitted Line', 'Fitted Quadratic', 'Location', 'northwest')
hold off;
0 Comments
See Also
Categories
Find more on Smoothing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!