In: Electrical Engineering
q1) using Matlab
make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
Good, definitely, this concern may also be clear up really trivially in a technique that does not require lsqlin, or anything fancy. There relatively is not any requirement for a linear constraint, for the reason that the constraint will probably be that the consistent parameter within the polynomial model is solely zero. So use backslash to estimate the mannequin coefficients, and simply go away out the constant term. Word that this works most effective to drive a factor by means of the starting place, due to the fact the factor (x,y) = (zero,zero) in a polynomial model implies that the constant term ought to be identically zero.
So, given a mannequin of the form
y = a1*x^three + a*x^2 + a3*x
we are able to fit it with ease as
a123 = [x.^3, x.^2, x]y;
where x and y are column vectors of data.
Which you could even use polyval to assess the polynomial, quite simply by means of appending a zero to the top of that vector f coefficients, for that reason
P = [a123;0];
in case you desired to force the mode to go by way of the factor
(x0,y0), the place these values aren't the starting place, then we
have to work slightly extra, however no longer a lot. While you can
do so with lsqlin, should you would not have that tool (or my own
LSE, as observed on the file exchange) simply do this easy
transformation:
xtr = x - x0;
a123 = [xtr.^3, xtr.^2, xtr](y - y0);
essentially, we've got now fit the model
y - y0 = a1*(x - x0)^3 + a*(x - x0)^2 + a3*(x - x0)
you will find that after x == x0, y ought to be estimated as
y0.
Analysis of this model is solely as convenient. That you could still use polyval, simply bear in mind to subtract off x0 from x first.
P = [a123;y0];
ypred = polyval(P,xpred - x0);
What occurs when we now have a more problematic concern, the place
might be you need to drive TWO aspects on the curve? Good, then,
you should utilize either lsqlin or my possess LSE. (observe that
LSE runs in R2015a with out a warning messages.)
Or, you probably have a trigonometric mannequin? If the model has nonlinear parameters in it, then you're going to have to use a nonlinear optimization. And relying on the mannequin, to force it by way of a given factor, that will require a nonlinear tool that may manage an equality constraint, so possibly fmincon. However usually, once more, relying on the mannequin, there could also be less difficult solutions. All of it depends upon the model.