スプライン曲線による図形変化
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ryosuke KIJIMA
am 15 Jan. 2020
Bearbeitet: michio
am 23 Jan. 2020
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/261804/image.png)
上図のような関数を,n=2,n=4,n=12の高次スプライン曲線で表現した場合,どのようなコードを使えばよろしいでしょうか?
イメージとしては、下図のようなものにしたいです.
![キャプチャ.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/261806/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.png)
0 Kommentare
Akzeptierte Antwort
Musashi Ito
am 15 Jan. 2020
多項式近似でよければ、多項式近似の関数があるみたいなので同じようなことができそうです。
% オリジナルデータの作成
x = 0:119;
y = [zeros(1,45) 90*ones(1,30) zeros(1,45)];
% 多項式近似
p2 = polyfit(x,y,2);
yp2 = polyval(p2,x);
p4 = polyfit(x,y,4);
yp4 = polyval(p4,x);
p12 = polyfit(x,y,12);
yp12 = polyval(p12,x);
% グラフの作成
figure
plot(x,y,'o-')
xlim([0 120])
ylim([0 120])
hold on
plot(x,yp2)
plot(x,yp4)
plot(x,yp12)
hold off
legend('元データ','2','4','12')
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu スプライン finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!