Curve fitting to a non-linear created equation

3 views (last 30 days)
Richard Wood
Richard Wood on 10 Apr 2020
Commented: darova on 10 Apr 2020
Hello everyone
I have a doubt concerning a fitting that I am trying to obtain. Suppose my independent variable is called "spatial_grid", while my dependent variable is called "mx_elastic". I want to fit, for each column of the "mx_elastic" array, this matrix to the "fitting_DWs_profile_elastic" function. Previously, I have stimated some initial values for the fitting, that it is, Delta1_elastic(1), A1_elastic(1), q1_elastic(1), Delta2_elastic(1), A2_elastic(1), and q2_elastic(1). The relevant part of my code is the following:
for i=2:length(physical_time_elastic)
% if q1_elastic(i)=q2_elastic(i)
% break
% else continue
% end
After stimate the parameters, I want to save them in the corresponding element of the array "A,q,Delta1,2_elastic". Moreover, I want to include a condition in my for loop. If q1_elastic(i)=q2_elastic(i), then do not take into account the i-th fitting, and stop the process. If that condition is not fulfilled, continue.
For some reason, without taking into account the if condition, I get the following error:
Error using fittype>iDeduceCoefficients (line 621)
The independent variable x does not appear in the equation expression.
Use x in the expression or indicate another variable as the independent variable.
Error in fittype>iCreateFromAnonymousFunction (line 516)
obj = iDeduceCoefficients(obj);
Error in fittype>iCreateFittype (line 357)
obj = iCreateFromAnonymousFunction( obj, varargin{:} );
Error in fittype (line 330)
obj = iCreateFittype( obj, varargin{:} );
Error in fit>iFit (line 165)
model = fittype( fittypeobj, 'numindep', size( xdatain, 2 ) );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in Post_Spin_Peltier_Treatment (line 219)
Probably a problem in the syntax of creating the function or fitting. Any ideas? Also, is the if condition well postulated?
  1 Comment
darova on 10 Apr 2020
I think your question is too complicated. You should simplify it

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!