Plotting of a prediction line over scatterplot
이전 댓글 표시
Hello, I am trying to run this program and plot the prediction line "y" over the scatterplot of age and ulna data points. However, the prediction line results with "doubling back" sections. Any suggestions as to fixing this so that the prediction line is smooth?
%Program Hollingrsquaredulna.m
%Load data
load ulnaestimation.txt;
data = ulnaestimation;
age = data(:,1);
ulna = data(:,2);
%Set parameters
a = 24.18358006;
b = 1.214523208;
K = 13.94615385;
y = (((K-b)*(age.^2))./((a.^2)+(age.^2)))+b;
%Compute RSS
residuals = sqrt(ulna) - sqrt(y);
squareresiduals = residuals.^2;
RSS = sum(squareresiduals);
%Compute denominator
residuald = sqrt(ulna) - mean(sqrt(ulna));
squareresiduald = residuald.^2;
denominator = sum(squareresiduald);
%Compute rsquared
rsquared = 1 - (RSS/denominator)
%Set parameters and compute AIC
q = length(age);
variance = RSS/q;
k = 3;
AIC = (q*log(variance))+2*k
scatter(age,ulna)
hold on
plot(age,y)
Any help is greatly appreciated!!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!