Problem using nlinfit with a multivariable function

I have the following code so far:
clear , clc , clf
% EXPERIMENTAL DATA =======================================================
load('dispvst.mat'); % Reads Data Set 1
X1 = dispvst(:,2); % Time Vector
Y1 = dispvst(:,1); % Displacement Vector
% REGRESSION ==============================================================
beta0 = [1 2];
FIT = nlinfit(X1,Y1,@FUN1,beta0); % Coefficient Fit
% Function ================================================================
function MODELFUN = FUN1(k,c,t)
m = 1; % Mass (kg)
Wn = sqrt(k/m); % Wn
E = c / (2*Wn); % E
Wd = Wn * sqrt(1-E^2); % Wd
A = sqrt((Wn*E*X1(1)) / Wd + X(1)^2); % A
Phi = atan(Wd/(E*Wn)); % Phi
MODELFUN = A*exp(-E*Wn*t)*sin(Wd*t+Phi); % Model Function
end
% END =====================================================================
MatLab gives me the following error code:
%===========================================================================
Error using nlinfit (line 213)
Error evaluating model function 'FUN1'.
Error in HW2P3 (line 16)
FIT = nlinfit(X1,Y1,@FUN1,beta0); % Coefficient Fit
Caused by:
Error using /
Matrix dimensions must agree.
=================================================================================
I can't figure out the correct syntax to use in order to use the function in the nlinfit function

답변 (0개)

카테고리

도움말 센터File Exchange에서 Chemistry에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2019년 2월 13일

댓글:

2019년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by