MATLAB: How to plot a 2D graph while one of the variable is a function of another variable

2d plotplot

I have 2 functions s1 and s1, both of which are as a function of a1 and a2.
s1 = @(a1,a2) (303.4*(1.52e-10 - 2.604e-7*a1^2)^(1/2) + 178.0*a1*a2^2 + 0.07335*a1^3)/a1
s2 = @(a1,a2) -(1.0*(4.396*a1^2*a2 + 4.547*a2^3 + 25.96*(5.559e-8 - 1.749e-6*a2^2)^(1/2)))/a2
I need to plot a1 as a function of s1 while s2 is varing in the interval -0.2:0.05:0.2, that is, for each step of s2 I need a specific graph a1 as a function of s1.

Best Answer

% note that other values are constant excrpt sigma1, sigma2, a1, and a2;
for sigma2 = -0.2:0.05:0.2
a1 = @(a2) sqrt((sigma2*c12*a2-c22*a2^3-sqrt((beta2*k1/2/Rm/ke*E2)^2-...
(beta2*(K3/Rm+K4*alpha2/Rm/ke)*omega2*a2)^2))/(c32*a2));
a1p = @(a2) sqrt((sigma2*c12*a2-c22*a2^3+sqrt((beta2*k1/2/Rm/ke*E2)^2-...
(beta2*(K3/Rm+K4*alpha2/Rm/ke)*omega2*a2)^2))/(c32*a2));
sigma1 = @(a2) (c21*(a1(a2))^3+c31*(a1(a2))*a2^2+sqrt((beta1*k1/2/Rm/ke*E1)^2-...
(beta1*(K3/Rm+K4*alpha1/Rm/ke)*omega1*a1(a2))^2))/c11/a1(a2);
psigma1 = @(a2) (c21*(a1p(a2))^3+c31*(a1p(a2))*a2^2+sqrt((beta1*k1/2/Rm/ke*E1)^2-...
(beta1*(K3/Rm+K4*alpha1/Rm/ke)*omega1*a1p(a2))^2))/c11/a1p(a2);
sigma1p = @(a2) (c21*(a1(a2))^3+c31*a1(a2)*a2^2-sqrt((beta1*k1/2/Rm/ke*E1)^2-...
(beta1*(K3/Rm+K4*alpha1/Rm/ke)*omega1*a1(a2))^2))/c11/a1(a2);
psigma1p = @(a2) (c21*(a1p(a2))^3+c31*a1p(a2)*a2^2-sqrt((beta1*k1/2/Rm/ke*E1)^2-...
(beta1*(K3/Rm+K4*alpha1/Rm/ke)*omega1*a1p(a2))^2))/c11/a1p(a2);
hold on
m = fplot(sigma1,a1,[1e-10,2]);
m.MeshDensity=1000;
m1 = fplot(psigma1,a1p,[1e-10,2]);
m1.MeshDensity=1000;
m2 = fplot(sigma1p,a1,[1e-10,2]);
m2.MeshDensity=1000;
m3 = fplot(psigma1p,a1p,[1e-10,2]);
m3.MeshDensity=1000;
end