Maximum value of the function
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
David Young
il 8 Nov 2011
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 Commenti
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!