1
我試圖繪製迴歸曲線:裝修正有序多項式
coef_fit = polyfit(norm_dist,norm_time,7);
y_fit = polyval(coef_fit,xlim);
plot(xlim,y_fit,'r');
但它始終是繪製相應的我通過訂單的行。
我試圖繪製迴歸曲線:裝修正有序多項式
coef_fit = polyfit(norm_dist,norm_time,7);
y_fit = polyval(coef_fit,xlim);
plot(xlim,y_fit,'r');
但它始終是繪製相應的我通過訂單的行。
問題是您使用的x
值是輸出ot xlim
,它是長度爲2的向量。你需要更多的價值定義x
載體:
norm_dist = sort(5*randn(1,50) + (1:50)); %// example x values
norm_time = 5*randn(1,50) + (1:50).^2; %// example y values
x = linspace(min(norm_dist), max(norm_dist), 200); %// define x values for plot
coef_fit = polyfit(norm_dist,norm_time,7);
y_fit = polyval(coef_fit,x);
plot(x,y_fit,'r');
hold on
plot(norm_dist, norm_time, 'b.') %// plot original points for comparison