필터 지우기
필터 지우기

How to use the function 'fit' on array of data and create an array of 'fit objects'

조회 수: 38 (최근 30일)
Eric Diaz
Eric Diaz 2015년 4월 16일
댓글: Eric Diaz 2015년 4월 17일
The 'fit' function does not seem to be friendly with arrays / matrices / variables.
for ii = 1:size(Y,2)
fitVar(ii)=fit(X,Y(:,ii),'exp1');
end
returns
Error using cfit/subsasgn (line 7)
Can't assign to an empty FIT.
while
for ii = 1:size(Y,2)
fit(X,Y(:,ii),'exp1');
end
works fine.
However, I can't do
fit(X,Y,'exp1')
if X is a dependent vector [10 x 1] which and Y is an independent matrix [10 x nSamples].
What is the solution?

답변 (1개)

Philip Caplan
Philip Caplan 2015년 4월 17일
Hi Eric - you cannot have arrays of "cfit" or "sfit" objects, which is the type returned by "fit". As such, you cannot index into this array because MATLAB thinks you are assigning (via subscripting) to an empty fit object. Instead, you can hold your "fit" objects in a cell array. The only change you need to make to your code is to use curly braces {} to index into "fitVar":
for ii = 1:size(Y,2)
fitVar{ii} = fit(X,Y(:,ii),'exp1');
end
  댓글 수: 1
Eric Diaz
Eric Diaz 2015년 4월 17일
Thank you for you're reply. This only partially solves the problem. Is there no way for "cfit" or "sfit" "fit" family of functions to do perform their job on matrices? Like other linear algebra matrix functions in MATLAB?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by