- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Shivani
2024-6-11
编辑:Shivani
2024-6-11
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 个评论
更多回答(1 个)
Image Analyst
2024-6-11
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!