need help to plot smooth of ๐‘ฆฬ‚ the least-squares fit to the data, over the range of x-values

์กฐํšŒ ์ˆ˜: 2 (์ตœ๊ทผ 30์ผ)
Ahmed
Ahmed 2020๋…„ 12์›” 2์ผ
ํŽธ์ง‘: Ameer Hamza 2020๋…„ 12์›” 2์ผ
function [coefficients, MSE] = pnnnfit(x, y, order)
coefficients = polyfit(x, y, order)
y_fitted = polyval(coefficients, x)
squaredError = (y - y_fitted) .^ 2
MSE = sum(squaredError)
plot(x, y,'o')
end
%x=[0 .5 1 1.5 2 2.5 3 3.5 4 4.5 5];
% y=[0 -5.27 -8.10 -8.46 -6.38 -1.84 5.15 14.59 26.48 40.83 57.63];
  ๋Œ“๊ธ€ ์ˆ˜: 1
KSSV
KSSV 2020๋…„ 12์›” 2์ผ
Read about interp1.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

๋‹ต๋ณ€ (1๊ฐœ)

Ameer Hamza
Ameer Hamza 2020๋…„ 12์›” 2์ผ
ํŽธ์ง‘: Ameer Hamza 2020๋…„ 12์›” 2์ผ
You are just plotting the actual points. The y_fitted will be smooth
x=[0 .5 1 1.5 2 2.5 3 3.5 4 4.5 5];
y=[0 -5.27 -8.10 -8.46 -6.38 -1.84 5.15 14.59 26.48 40.83 57.63];
pnnnfit(x, y, 2);
function [coefficients, MSE] = pnnnfit(x, y, order)
coefficients = polyfit(x, y, order)
y_fitted = polyval(coefficients, x)
squaredError = (y - y_fitted) .^ 2
MSE = sum(squaredError)
plot(x, y,'o')
hold on
plot(x, y_fitted)
end

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Smoothing์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by