Solving/plotting a nonlinear equation for multiple values
이전 댓글 표시
Hello all,
I am a mechanical engineering student working on some Applied Thermodynamics homework and am having trouble getting the values I need to plot a nonlinear equation. I have (on paper) determined that my nonlinear equation is as follow:
2*sqrt(P)*((x)^1.5) + .10905*x- 0.0363 = 0
where P is a pressure and x happens to be a molecular concentration in this case. So, I can solve the above equation for set values of P using the following function file (when P = 1).
function [x,P] = myfun(x)
F = 2*sqrt(1)*((x)^1.5) + .10905*x- 0.03635;
end
and the commands:
x0 = 0.5;
[x,fval] = fsolve(@myfun,x0)
But what I want is to define P as an array like [0.1:0.1:100] and be able to solve all of those values at once instead of having to get each one individually. I was wondering if this was possible using the above approach or if I should be looking at another method. Thank you in advance for any guidance you can give me. Still kind of a Matlab novice if you couldn't already tell.
채택된 답변
추가 답변 (1개)
Alfonso Nieto-Castanon
2013년 11월 26일
편집: Alfonso Nieto-Castanon
2013년 11월 26일
Perhaps something like:
f = @(x,P)2*sqrt(P)*x^1.5 + .10905*x- 0.0363;
P = .1:.1:100;
x0 = 0.1;
[x,fval] = arrayfun(@(P)fzero(@(x)f(x,P),x0), P);
plot(P,x);
카테고리
도움말 센터 및 File Exchange에서 Thermal Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!