How do I plot the relationship between two variables in an inseparable function?
显示 更早的评论
I am trying to plot the relationship between the variables S and t in the following equation:
S = 8-0.7*t+2.5*log(8/S)
However, I do not know how to create a plot of S vs t given that the function is inseparable. What is the syntax in Matlab for plotting a function of more than one variable?
采纳的回答
更多回答(2 个)
Massimo Zanetti
2016-10-9
(Erroneously canceled my previous answer) Not all s,T verify the equation. To find them use fsolve https://it.mathworks.com/help/optim/ug/fsolve.html
To just plot, you need to see the equation as a surface of t,s as follows:
t=-2:.1:2;
s=0:.1:5;
[T,S]=meshgrid(t,s);
F = 8-0.7*T+2.5*log(8./S)-S;
surf(T,S,F);
xlabel('t');
label('S');
You can also look at the points that verify the equation by
contour(F,[0,0]);
Walter Roberson
2016-10-9
The equations are separable:
t = 80/7+(25/7)*ln(8/S)-(10/7)*S
or
S = (5/2)*LambertW((16/5)*exp(16/5-(7/25)*t))
There are additional complex solutions for S, all of the other branches of LambertW; you did not specify the solution domain
You can also plot directly:
ezplot(@(t,S) -S + 8 - 0.7 .* t + 2.5 .* log(8./S), [-10 10])
类别
在 帮助中心 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!