cell配列内でのpolyfitの使い方について
4 views (last 30 days)
Show older comments
1×5のcellがあり、その中にそれぞれx行2列のデータが入っています。
xはcellごとにサイズが異なります。
polyfitを使用してそれぞれのcellに格納されている行列に対して、近似直線の傾きと切片を得たいのです。
出力としては1×5のcellでそれぞれに傾きと切片が入っているイメージです。
cellfunを使用するのですが、x行2列を入力引数に入れる書き方が分からずうまくいきません。
どなたかご教示ください。
0 Comments
Answers (1)
Atsushi Ueno
on 9 May 2023
C = cell(1,5); % 1×5のcell
C = cellfun(@(x) rand(randi(10),2),C,'uni',false) % それぞれx行2列のデータ
cellfun(@(x) polyfit(x(:,1),x(:,2),1),C,'uni',false) % 1×5のcell、それぞれに傾きと切片
See Also
Categories
Find more on Image Processing and Computer Vision 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!