All,
I am trying to use the "Fit" feature in my code for a logarithmic type, and it works fine when I use a simple "Plot", but when I try to plot it to app.UIAxes on app designer I get the error : "Error using plot. Data must be numeric, datetime, duration or an array convertible to double." Would anyone know why it works for one but not the other? Below is my code that works in creating "Figure 1".
x = [0.0498 0.0975 0.1575 0.2052 0.0689 0.1182 0.1761];
y = [63.43404943 63.35712264 97.36962948 101.6632456 70.12364289 100.7818903 98.74765614];
myfittype = fittype('a + b*log(x)','dependent',{'y'},'independent',{'x'},'coefficients',{'a','b'});
myfit = fit(x',y',myfittype);
a = myfit.a;
b = myfit.b;
%Succesful using:
plot(myfit)
%I want to change to, but gives me an error:
%plot(app.UIAxes, myfit)
Successful plot:

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Jan. 2022

0 Stimmen

plot() of a fitobj is not compatible with UIAxes . It uses plot() and related calls without attempting to parent them to any axes, so it is going to work on the current "traditional" axes... except that depending on the options you specify it might subplot() to create new traditional axes.
You will need to extract the information from the fit object and use it to create your own plot.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by