複数の多項式近似
10 views (last 30 days)
Show older comments
上の写真のように、ある物質の5秒間の温度変化を数字で表したCSVファイルがあります。例えば、0秒の時の温度はfile_0に入っており、1秒後の温度はfile_1に入っています。合計で172800点あるのですが、これら全ての点を2次の多項式近似として書き出す方法はあるでしょうか?
つまり172800点全ての点の5秒間の温度変化を数式で表すことが出来るかということです。
もし書き出せたら、y=2x²+3x+5のような式が172800個できるということになります。
0 Comments
Answers (1)
Atsushi Ueno
on 10 Dec 2022
係数は降べきの順、長さは 3 で () が 360*480=172800 組あります。
d(:,:,1) = readmatrix('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1226132/file_0.CSV');
d(:,:,2) = readmatrix('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1226137/file_1.CSV');
d(:,:,3) = readmatrix('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1226142/file_2.CSV');
d(:,:,4) = readmatrix('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1226147/file_3.CSV');
d(:,:,5) = readmatrix('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1226152/file_4.CSV');
[X,Y,Z] = size(d) % x,y 軸の項目も含む為、縦横1ずつサイズが大きい
for x = 2:X
for y = 2:Y
p{x-1,y-1} = polyfit(0:4,d(x,y,:),2);
end
end
% 計算された係数を確認
size(p) % 係数の組が360*480=172800セット
p{1,1}
p{360,480}(3) % f{x,y}(n)の形で個々の係数Pnを取り出せる
See Also
Categories
Find more on Creating and Concatenating Matrices 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!