MATLAB: Solve an expression and plot

plotsolve

Suppose, for each alpha, I have to find a delta which is the highest positive root of the equation A^2-4*B*beta=0. The expression of A, B are given in terms of alpha and delta. How to get that and how to plot alpha vs delta plot.
beta=0.85;gamma=.15;theta=0.1;
alpha=.303:.001:5
syms delta
A=-alpha*beta + alpha.*delta + gamma*beta + beta;
B=alpha.*theta*(beta -delta) + gamma*beta;
rr=solve(A^2-4*B*beta == 0)
plot(alpha,rr)

Best Answer

beta = 0.85; gamma = .15; theta = 0.1;
alpha = .303: .001: 5;
syms Alpha delta
A = -Alpha * beta + Alpha .* delta + gamma * beta + beta;
B = Alpha .* theta * (beta - delta) + gamma * beta;
rr = solve( A^2 - 4*B*beta, delta);
rrt = double(subs(rr, Alpha, alpha(1));
[maxrrt, idx] = max(rrt);
maxrr = rr(idx);
rrpos = double(subs(maxrr, Alpha, alpha));
plot(alpha, rrpos)