cell配列内でのpolyfitの使い方について
Afficher commentaires plus anciens
1×5のcellがあり、その中にそれぞれx行2列のデータが入っています。
xはcellごとにサイズが異なります。
polyfitを使用してそれぞれのcellに格納されている行列に対して、近似直線の傾きと切片を得たいのです。
出力としては1×5のcellでそれぞれに傾きと切片が入っているイメージです。
cellfunを使用するのですが、x行2列を入力引数に入れる書き方が分からずうまくいきません。
どなたかご教示ください。
Réponses (1)
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、それぞれに傾きと切片
1 commentaire
flower
le 9 Mai 2023
Catégories
En savoir plus sur Multidimensional Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!