how can I find the intersection of two surface

3 views (last 30 days)
Hi, I wrote the code below to find the intersection of two surfaces "cdot: and "ctdot", but it has an error : Z must be a matrix, not a scalar or vector.
Could you please tell me how solve it, thanks for any help.
vplc=0.16;
delta=0.1;
Ktau=0.045;
Kc=0.1;
K=0.0075;
Kp=0.15;
gamma=5.5;
Kb=0.4;
alpha0=delta*6.81e-6/(0.002);
alpha1=delta*2.27e-5/(0.002);
Ke=7;
Vs=0.002;
Ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
tau_max=0.176;
Vss=0.044;
A=(-(Vss.*c.^2)./(Ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(Ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
p=(vplc.*c.^2./(c.^2+kplc.^2))./ki;
h=(-(0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*c.^2.*gamma.*ct.*Kf))));
G1=alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4));
G2=((1-h)./tau_max).*c.^4;
Fc=(4.*gamma.*Kf).*((c.^3.*p.^2.*h.*ct)./(Kb.*Kp.^2.*Ktau.^4))-(2.*Vss.*c./Ks.^2);
Fct=((gamma.*Kf.*(c.^4).*(p.^2).*h)./(Kb.*Kp.^2.*Ktau.^4))+((Vs.*K.*gamma.^2)./(Ks.^2))-((4.*gamma.^4.*ct.^3.*alpha1.*Ke.^4)./(Ke.^4+(gamma.*ct).^4).^2);
Fh=(gamma.*Kf.*c.^4.*p.^2.*ct)./(Kb.*Kp.^2.*Ktau.^4);
cdot=@(ct,c)(((gamma.*Kf.*(c.^4).*(p.^2).*h)./(Kb.*Kp.^2.*Ktau.^4))+((Vs.*K.*gamma.^2)./(Ks.^2))-((4.*gamma.^4.*ct.^3.*alpha1.*Ke.^4)./(Ke.^4+(gamma.*ct).^4).^2)).*(alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4)))+((gamma.*Kf.*c.^4.*p.^2.*ct)./(Kb.*Kp.^2.*Ktau.^4)).*(((1-h)./tau_max).*c.^4);
ctdot=@(ct,c)(-(alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4))).*((4.*gamma.*Kf).*((c.^3.*p.^2.*h.*ct)./(Kb.*Kp.^2.*Ktau.^4))-(2.*Vss.*c./Ks.^2)));
ct = 0:.1:2.5;
c = 0:.1:2.5;
[Ct,C] = meshgrid(ct,c);
figure
surf(Ct,C,cdot(Ct,C)-ctdot(Ct,C))
hold on
contour3(C,Ct,cdot(Ct,C)-ctdot(Ct,C), [0 0], '-r', 'LineWidth',2)

Accepted Answer

Star Strider
Star Strider on 20 Sep 2022
Edited: Star Strider on 20 Sep 2022
MATLAB is case-sensitive so ‘ct’ ~= ‘Ct’ (and so for the others) in the ‘cdot’ and ‘ctdot’ calls.
I would like to run this to demonstrate that, however ‘c’ is nowhere to be found.
vplc=0.16;
delta=0.1;
Ktau=0.045;
Kc=0.1;
K=0.0075;
Kp=0.15;
gamma=5.5;
Kb=0.4;
vss=0.044;
alpha0=delta*6.81e-6/(0.002);
alpha1=delta*2.27e-5/(0.002);
Ke=7;
Vs=0.002;
Ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
tau_max=0.176;
Vss=0.044;
ct = 0:.1:2.5;
c = 0:.1:2.5;
A=(-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
Unrecognized function or variable 'ks'.
p=(vplc.*c.^2./(c.^2+kplc.^2))./ki;
h=(-(0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*c.^2.*gamma.*ct.*Kf))));
G1=alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4));
G2=((1-h)./tau_max).*c.^4;
Fc=(4.*gamma.*Kf).*((c.^3.*p.^2.*h.*ct)./(Kb.*Kp.^2.*Ktau.^4))-(2.*Vss.*c./Ks.^2);
Fct=((gamma.*Kf.*(c.^4).*(p.^2).*h)./(Kb.*Kp.^2.*Ktau.^4))+((Vs.*K.*gamma.^2)./(Ks.^2))-((4.*gamma.^4.*ct.^3.*alpha1.*Ke.^4)./(Ke.^4+(gamma.*ct).^4).^2);
Fh=(gamma.*Kf.*c.^4.*p.^2.*ct)./(Kb.*Kp.^2.*Ktau.^4);
cdot=@(ct,c)(((gamma.*Kf.*(c.^4).*(p.^2).*h)./(Kb.*Kp.^2.*Ktau.^4))+((Vs.*K.*gamma.^2)./(Ks.^2))-((4.*gamma.^4.*ct.^3.*alpha1.*Ke.^4)./(Ke.^4+(gamma.*ct).^4).^2)).*(alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4)))+((gamma.*Kf.*c.^4.*p.^2.*ct)./(Kb.*Kp.^2.*Ktau.^4)).*(((1-h)./tau_max).*c.^4);
ctdot=@(ct,c)(-(alpha0+(alpha1.*Ke.^4./((gamma.*ct).^4+Ke.^4))).*((4.*gamma.*Kf).*((c.^3.*p.^2.*h.*ct)./(Kb.*Kp.^2.*Ktau.^4))-(2.*Vss.*c./Ks.^2)));
% ct = 0:.1:2.5;
% c = 0:.1:2.5;
[Ct,C] = meshgrid(ct,c);
figure
surf(Ct,C,cdot(Ct,C)-ctdot(Ct,C))
hold on
contour3(C,Ct,cdot(Ct,C)-ctdot(Ct,C), [0 0], '-r', 'LineWidth',2)
.
  17 Comments
Torsten
Torsten on 23 Sep 2022
At least cdot(ct,c) = 0 is empty for ct >=0.
ctdot(ct,c) = 0 gives two implicit curves symmetric to the ct-axis.
Star Strider
Star Strider on 23 Sep 2022
Originally, the objective was to determine the intersection:
figure
surf(Ct,C,cdot(Ct,C)-ctdot(Ct,C))
hold on
contour3(C,Ct,cdot(Ct,C)-ctdot(Ct,C), [0 0], '-r', 'LineWidth',2)
I am not certain where we are at this point.

Sign in to comment.

More Answers (0)

Categories

Find more on Contour 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!