Using two models on a function and plot it.
Show older comments
Hello.
I want to plot a function of x. Where at one value of x the mathematical model changes. How would I do that?
This is my code and the two models are rLin and rMet. When "Vsn" reaches a value of 0.95 the rMet model is used, before that rLin is used if "Vsn" > 0.
tx = 40 * 10^-10;
ex = 3.45*10^-13;
on = 180;
Vn = 0.25;
WLn = 0.12/1.4;
B = (on * (ex/tx)*WLn);
rLin = @(Vsn) B*(1.2 - Vn - (Vsn/2)).*Vsn;
rMet = @(Vsn) (B/2)*(1.2 - Vn)^2;
Answers (1)
Star Strider
on 13 Feb 2017
Try this:
VsnFcn = @(Vsn) rLin(Vsn).*(Vsn >0 & Vsn<=0.95) + rMet(Vsn).*(Vsn>0.95);
also note that ‘rMet’ does not actually use ‘Vsn’ in its calculation.
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!