How to plot graph of value of variable when a parameter is varied
Mostra commenti meno recenti
Hi all,
I have a system of equations and I would like to solve for e, τ, and k. However, I want to assume that the parameter R can take on several different values (e.g. 0.5, 1, 1.5). In particular, I hope to plot a graph of how the solution for any of my variables e, τ or k varies with R. I am really struggling with how this can be implemented in MATLAB. Any help will be much appreciated.

Risposta accettata
Più risposte (1)
Torsten
il 9 Apr 2020
0 voti
Your equations can only be solved for one value of R, namely R = 0.3 + 0.366*exp(-0.3).
This can be seen by dividing equation 1 by equation 3.
4 Commenti
Ameer Hamza
il 9 Apr 2020
Torsten, e is not Euler's number in this question. OP used e to denote a variable.
Torsten
il 9 Apr 2020
ok, then at least we can explicitly solve for e depending on R.
Taking the reciprocals of all the 6 expressions and inserting the result for e from the first step, we can solve for tau and k since we have a linear system of equations.
Teck Lim
il 9 Apr 2020
Ameer Hamza
il 9 Apr 2020
Torsten's analysis is correct. This system does have a closed-form solution. I used a symbolic toolbox to solve this system of equation, and it gives more accurate results (as expected) at R=0.5 as compared to the numeric solver. Following code shows the solution with symbolic approach
syms e tau k R
eq1 = 1./(0.8*e.^0.7-e-tau-k) - 0.336*e.^-0.3./(tau+R.*k);
eq2 = 1./(0.8*e.^0.7-e-tau-k) - 0.5./tau;
eq3 = 1./(0.8*e.^0.7-e-tau-k) - (R-0.3)./(tau+R.*k);
r = [0.5 1 1.5];
sols = zeros(numel(r), 3);
for i=1:numel(r)
sol = solve([eq1==0 eq2==0 eq3==0], [e tau k]);
sols(i,1) = subs(sol.e(1), R, r(i));
sols(i,2) = subs(sol.tau(1), R, r(i));
sols(i,3) = subs(sol.k(1), R, r(i));
end
sols = double(sols);
plot(r, sols);
legend({'e', 'tau', 'k'});
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
