Curve fitter app does not work

I used online MATLAB; however, I could not fit the curve using Curve fitter app.
There are errors presented at the command window as;
Error in matlab.ui.internal.toolstrip.base.ActionInterface>@(event,data)PropertySetCallback(this,event,data) (line 40)
this.PropertySetListener = addlistener(this.Peer, 'propertySet', @(event, data) PropertySetCallback(this, event, data));
Error in viewmodel.internal.factory.ManagerFactoryProducer>@(src,event)callback(src,viewmodel.internal.factory.ManagerFactoryProducer.convertStructToEventData(event)) (line 79)
proxyCallback = @(src, event)callback(src, ... > In cfapp.internal.curvefitter.ui.toolstrip/FitSectionView/set.AutoFitState (line 60)
In cfapp.internal.curvefitter.ui.toolstrip/FitSectionView/autoFitRadioButtonClicked (line 138)
In cfapp.internal.curvefitter.ui.toolstrip.FitSectionView>@(varargin)this.autoFitRadioButtonClicked(varargin{:}) (line 116)
In internal.Callback.execute (line 128)
In matlab.ui.internal.toolstrip.base/Action/PropertySetCallback (line 782)
In matlab.ui.internal.toolstrip.base.ActionInterface>@(event,data)PropertySetCallback(this,event,data) (line 40)
In viewmodel.internal.factory.ManagerFactoryProducer>@(src,event)callback(src,viewmodel.internal.factory.ManagerFactoryProducer.convertStructToEventData(event)) (line 79)

7 Comments

You'll have to provide the code you tried to execute including the data to reproduce the error...nothing can do without the specifics of the case.
That doesn't look like the complete error message. Were there one or two more lines displayed in red before the start of the error message that you copied and pasted into this discussion? If so what were they?
Here is the full version. Sorry, I missed the upper part.
Warning: Error occurred while executing the listener callback for event FittingDataChanged defined for class cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogView:
Execution of script fit as a function is not supported:
/MATLAB Drive/fit.m
Error in cfapp.internal.curvefitter.model.Fitdev>iCallFit (line 1514)
fit( input, output, aFittype, fitOptions );
Error in cfapp.internal.curvefitter.model.Fitdev/fit (line 552)
[aFit, aGoodness, anOutput, aWarning, anError, aConvergence] = iCallFit( ...
Error in cfapp.internal.curvefitter.model.Fitdev/updateFit (line 842)
fit(this);
Error in cfapp.internal.curvefitter.model.Fitdev/doFittingDataUpdatedActions (line 860)
updateFit(this);
Error in cfapp.internal.curvefitter.model.Fitdev/updateFittingData (line 367)
doFittingDataUpdatedActions(this);
Error in cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogPresenter/fittingDataChangedCallback (line 133)
this.DisplayedFitdev.updateFittingData(fieldName, metaData);
Error in cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogPresenter>@(varargin)this.fittingDataChangedCallback(varargin{:}) (line 40)
this.addListener(this.FittingDataDialogView, 'FittingDataChanged', @this.fittingDataChangedCallback);
Error in cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogView/fittingDataChanged (line 343)
this.notify('FittingDataChanged', evtData);
Error in cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogView>@(src,evt)this.fittingDataChanged(src,evt,'Y') (line 256)
this.addListener(this.YFittingDataSelector, 'DataChanged', @(src, evt) this.fittingDataChanged(src, evt, 'Y'));
Error in cfapp.internal.curvefitter.ui.dataselection.DataSelector/inputWorkspaceDropDownValueChangedCallback (line 123)
this.notify('DataChanged', cfapp.internal.curvefitter.ui.dataselection.ArrayEventData(selectedVarName));
Error in cfapp.internal.curvefitter.ui.dataselection.DataSelector>@(s,e)this.inputWorkspaceDropDownValueChangedCallback(s,e) (line 94)
'ValueChangedFcn', @(s, e) this.inputWorkspaceDropDownValueChangedCallback(s, e));
Error in cfapp.internal.curvefitter.ui.dataselection.WorkspaceDropDown/privateValueChangedFcn (line 247)
feval(this.ValueChangedFcn, s, e); Error in cfapp.internal.curvefitter.ui.dataselection.WorkspaceDropDown>@(varargin)this.privateValueChangedFcn(varargin{:}) (line 242)
this.PrivateDropDown.ValueChangedFcn = @ this.privateValueChangedFcn; > In cfapp.internal.curvefitter.ui.dataselection/FittingDataDialogView/fittingDataChanged (line 343)
In cfapp.internal.curvefitter.ui.dataselection.FittingDataDialogView>@(src,evt)this.fittingDataChanged(src,evt,'Y') (line 256)
In cfapp.internal.curvefitter.ui.dataselection/DataSelector/inputWorkspaceDropDownValueChangedCallback (line 123)
In cfapp.internal.curvefitter.ui.dataselection.DataSelector>@(s,e)this.inputWorkspaceDropDownValueChangedCallback(s,e) (line 94)
In cfapp.internal.curvefitter.ui.dataselection/WorkspaceDropDown/privateValueChangedFcn (line 247)
In cfapp.internal.curvefitter.ui.dataselection.WorkspaceDropDown>@(varargin)this.privateValueChangedFcn(varargin{:}) (line 242)
In appdesservices.internal.interfaces.model/AbstractModel/executeUserCallback (line 310)
In matlab.ui.control.internal.controller/ComponentController/handleUserInteraction (line 442)
In matlab.ui.control.internal.controller/DropDownController/handleEvent (line 61)
In appdesservices.internal.interfaces.controller.AbstractController>@(varargin)obj.handleEvent(varargin{:}) (line 214)
In viewmodel.internal.factory.ManagerFactoryProducer>@(src,event)callback(src,viewmodel.internal.factory.ManagerFactoryProducer.convertStructToEventData(event)) (line 79)
I have just define d and f variables and plot them. There is no other code in the script file.
Then, I just use 'curve fitter app' and select d = x axis, F= y axis to fit curve; however, it does not work.
I remembered I could do like this without problem sometime earlier.
I have open the fit curve file earlier and it showed like this.

Sign in to comment.

 Accepted Answer

Steven Lord
Steven Lord on 19 Jun 2024
Rename your script fit.m so it does not conflict with the fit function from Curve Fitting Toolbox. The app uses fit as part of its execution.

4 Comments

Isn't it possible for the MATLAB software to give a warning if a function name collides with an internal MATLAB function ? In the meantime, I've read about so many occurences of this problem in the forum that I think it could be worth thinking about such a check by TMW.
It resolves now!
Thank you so much for your help :)
FYI, I have 2 files name collide with MATLAB function (fit.m and filter.m). After I renamed both, it works properly now.
@Torsten For built-in functions, MATLAB issues a warning if you cd into a directory that contains a MATLAB code file of the same name or add that directory to the MATLAB search path. Here I'll make such a directory containing a sin.m file (sin is most definitely a built-in function.)
cd(tempdir)
name = 'stuff2129806';
mkdir(name)
fid = fopen(fullfile(name, 'sin.m'), 'wt');
fprintf(fid, 'function y = sin(y)');
fclose(fid);
When I cd into that directory, I receive a warning. [I'm not sure offhand why it displays twice, once like it was being disp-ed and once as a warning.]
cd(name)
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Now I'll cd out of that directory (no warning necessary here) then add that directory to the search path.
cd ..
P = path;
addpath(name)
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
For MATLAB code files, like in this case fit.m (from Curve Fitting Toolbox) or something like ode45.m (in MATLAB), it does not. First let's restore the path to how it was before I called addpath so the sin.m is no long "visible" to MATLAB, then make an ode45.m. This is a function in MATLAB.
path(P)
which -all ode45
/MATLAB/toolbox/matlab/funfun/ode45.m /MATLAB/toolbox/nnet/deep/@dlarray/ode45.m % dlarray method
fid = fopen(fullfile(name, 'ode45.m'), 'wt');
fprintf(fid, 'function z = ode45(y)\nz = y.^2;');
fclose(fid);
Now if I cd into that directory I receive the same warning about sin but no warning about ode45. You can also see that the ode45.m I created is visible to MATLAB and callable.
cd(name)
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
which -all ode45
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Warning: Function sin has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
/tmp/stuff2129806/ode45.m /MATLAB/toolbox/matlab/funfun/ode45.m % Shadowed /MATLAB/toolbox/nnet/deep/@dlarray/ode45.m % dlarray method
ode45(1:10)
ans = 1x10
1 4 9 16 25 36 49 64 81 100
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Should MATLAB warn about all MATLAB code files that share a name with a file in a MathWorks toolbox and/or add-on you have installed? I don't know what the performance implications of that check would be or just how noisy it would be. You can see how many times the warning about sin.m was issued above. Now picture the directory had 10, 20, 100 functions that share a built-in function's name.
It also wouldn't necessarily detect files in a product you don't have installed now but install later as an Add-On (or we'd have to redo the check as soon as you installed the new Add-On, which could be a MathWorks product.) Then there are files in namespaces that you can import -- do those warn about conflicts as soon as that namespace is imported? What implication does that have on existing users of import?
And why should MathWorks toolboxes get all the protection? Should toolboxes authored by developers outside MathWorks (like Psychtoolbox, which comes up reasonably often on Answers) be able to buy into warning if others shadow their functions?
If you feel strongly it could help it's worth an enhancement request to Technical Support, particularly if you have a list of Answers posts where it would have avoided the problem in the post entirely. [Our developers love real-world use cases to consider when designing features! And no, that's not sarcastic.] But IMO there are enough questions and potential gotchas in my mind that I think it would warrant some careful thought and design to decide when/how/if to implement it.

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Release

R2024a

Community Treasure Hunt

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

Start Hunting!