matlabdebuggingcurve-fittingdisabled-controlundocumented-behavior

How can we use the Curve Fitting Tool during debugging?


MATLAB's Curve Fitting App (previously "tool", hence, cftool) is a graphical tool for interactive curve fitting1.

The general way of working with this tool is by choosing variables from the workspace:

enter image description here However, during debugging, data selection is disabled (this is documented):

enter image description here

... which is quite a nuisance, since we must save the data to a file, and either quit debugging or open a new instance of MATLAB before we can load this data again and use it in cftool.

I would assume that the reason for disabling the inputs is because during debugging we usually have multiple workspaces, and so iterating through them or providing user choice of the workspace is too cumbersome in terms of UX - so the developers decided to disable the inputs until such time that only a single workspace exists.

My question is this: How can we disable the "debugging detection" of cftool or otherwise specify the workspace that we're interested in, so that we can use cftool during debugging?


Solution

  • I did some digging, and here's what I found:

    So now we can do the following:

    X = 0:9;
    Y = 10:-1:1;
    cftool();
    % <select the X and Y variables in cftool to get a decreasing slope>.
    unlockCftool();
    % <enter debug mode, for example using: dbstop in unlockCftool; unlockCftool(); >
    assignin('base', 'X', 5:-1:-4);
    % <re-select X to update the data - resulting in a rising slope>.