The problem of plotting

13 views (last 30 days)
Dmitry
Dmitry on 26 Feb 2023
Answered: Walter Roberson on 26 Feb 2023
I make a curve fitting selection for a set of points and build a graph that includes: a set of points for which the fitting is performed(f), a fitted curve(dv,tv) and another set of points(mlbt1, mlbt2). But for some unknown reason, the schedule is not being built. How can this be fixed?
P.s. I have attached all the data files to the question.
My code:
load tv
load dv
load mlbt1
load mlbt2
t_v = tv';
d_v = dv';
f = fit(d_v,t_v,'rat55');
Warning: Start point not provided, choosing random start point.
plot(f, mlbt1, mlbt2,'o', dv,tv,'-b');
Error using cfit/plot>parseinput
Argument 6 is incorrect

Error in cfit/plot (line 46)
[S1,xdata,ydata,S2,outliers,S3,ptypes,conflev] = parseinput(alltypes,varargin);
grid on

Answers (2)

the cyclist
the cyclist on 26 Feb 2023
Edited: the cyclist on 26 Feb 2023
A quick look at the documentation for fit suggests to me that you syntax you used (to include two plots in one figure) is not valid. Try this instead. (I'm not certain this exact plot is what you intended, but I'm guessing you can edit to get what you wanted.)
load("dv","dv")
load("tv","tv")
load("mlbt1","mlbt1")
load("mlbt2","mlbt2")
t_v = tv';
d_v = dv';
f = fit(d_v,t_v,'rat55');
Warning: Start point not provided, choosing random start point.
figure
hold on
plot(f, mlbt1, mlbt2,'o');
plot(dv,tv,'-b');
grid on

Walter Roberson
Walter Roberson on 26 Feb 2023
When you plot() a cfit object https://www.mathworks.com/help/curvefit/cfit.plot.htm then you cannot specify multiple datasets to plot.
plot(f, mlbt1, mlbt2,'o'
that part would correspond to the syntax
In order to have more parameters after that, you would have to be using
plot(...,ptype,level)
but ptype for that syntax is a character vector or scalar string object, which your dv is not.
If you want to plot tv vs dv on the same line you will need to
plot(f, mlbt1, mlbt2,'o');
hold on
plot(dv,tv,'-b');
hold off

Categories

Find more on Fit Postprocessing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!