近似直線が端の方だけ点線になります.該当する近似曲線をすべて点線にするためにはどうすればよいですか?
Show older comments
異なるデータに対して近似直線のグラフを書きます.
データ2で点線を指定しているにもかかわらず,添付図のように中途半端な点線になります.
グラフを拡大しても該当する近似直線はなぜか点線になっていません.
ご教示のほどよろしくお願い申し上げます.
y1 = [59.1 60.8 59.2 72.5 64.2 63.4 58.5 60.6 78.4 44.6 58.7 41.9 39.9 38.9 61.7 39.7 29.9 28.4 29.3 27.5 25.3 -5.2 7.8 2.0 -4.8 -13.2 10.0 4.4 1.5]';
x1 = [3.0 2.6 3.9 3.0 3.5 3.2 3.4 3.9 3.6 3.3 3.3 3.3 2.9 3.3 3.6 3.2 2.7 3.0 3.5 3.7 3.7 2.8 2.9 3.4 3.8 3.4 2.9 3.2 3.2]';
y2 = [56.4 60.2 61.7 73.7 64.2 65.2 75.7 62.3 117.7 44.6 59.8 44.7 49.9 44.3 65.8 33.8 35.0 36.7 35.5 47.6 39.8 42.5 18.6 3.6 76.9 52.3 44.4 12.5 36.2]';
x2 = [3.5 3.4 3.3 3.1 3.6 4.0 3.8 2.9 3.2 2.9 3.4 3.0 3.2 3.2 3.0 3.3 3.2 3.3 2.9 3.5 3.2 3.3 3.5 3.3 3.1 3.2 2.8 2.6 3.2]';
%% データプロット1
X1 = [ones(length(x1),1) x1];
b1 = X1\y1;
yCalc1 = X1*b1;
plot(x1,y1,'ko',x1,yCalc1,'k-','MarkerSize',6)
hold on
%% データプロット2
X2 = [ones(length(x2),1) x2];
b2 = X2\y2;
yCalc2 = X2*b2;
plot(x2,y2,'k^',x2,yCalc2,'k--','MarkerSize',6)
legend('Data1','Linear fit','Data2','Linear fit')
hold off

Accepted Answer
More Answers (1)
KT
on 9 Jul 2022
0 votes
Categories
Find more on グラフィックス パフォーマンス 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!
