スプライン曲線による図形変化
조회 수: 1 (최근 30일)
이전 댓글 표시
![](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
채택된 답변
Musashi Ito
2020년 1월 15일
多項式近似でよければ、多項式近似の関数があるみたいなので同じようなことができそうです。
% オリジナルデータの作成
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!