Maximum value of the function
3 ビュー (過去 30 日間)
古いコメントを表示
P=1.008*V-(10^-10)*V*exp(V/0.026);
I want to find the maximum value of P for some value of V. What is an easy way.
And I am trying to plot V vs P with the following code but not able to:
subs V;
V=0:0.001:0.6;
P(V)=1.008*V-(10^-10)*V*exp(V/0.026);
plot(V,P);
0 件のコメント
回答 (1 件)
David Young
2011 年 11 月 8 日
There are three problems with your code. First, this is a normal numerical computation, so you don't need subs V at the start.
Second, to multiply two vectors element by element you need to use the .* operator (* is matrix multiplication). In fact, it's clearest to use .* for all the multiplications here, as none is a matrix multiplication.
Third, P(V) on the left means "assign the result to those elements of P indexed by V". (Remember, this is code, not a mathematical formula.) V doesn't make sense as an index vector, but all you need to do is assign the result vector to P as a whole. Thus the corrected code is
P=1.008.*V-(10^-10).*V.*exp(V./0.026);
or, with clearer layout and the constant expressed conventionally,
P = 1.008 .* V - 1e-10 .* V .* exp(V ./ 0.026);
On your first question, to find the maximum you can differentiate the formula analytically, set the result to zero, solve for the value of V, and substitute to get the value of P.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!