solve an expression and plot

3 Ansichten (letzte 30 Tage)
Atom
Atom am 3 Jun. 2013
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)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Jun. 2013
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)

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 3 Jun. 2013
Bearbeitet: Azzi Abdelmalek am 3 Jun. 2013
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;
for k=1:numel(A)
rr{k}=solve(A(k).^2-4*B(k)*beta == 0);
end
  2 Kommentare
Walter Roberson
Walter Roberson am 3 Jun. 2013
After which you would need the step of finding the highest positive root for each rr{:}
Atom
Atom am 4 Jun. 2013
Thanks for your reply. delta may some times given one +ve, one -ve roots and 2 positive. I need the largest positive value of delta for each alpha. I also would like to plot(alpha, delta).

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by