Plot a complicated equation

Hello,
I am trying to plot a complicated equation involving rationals and trigonometric functions. The equation is:
Cm = -m * ((b/a)^2.5 * q^0.5) / (dF/dq)
where,
F = (b/a)^4 * ((2*q^2 - (a^2/b^2))^2 * (q^2 - (a^2/p_2^2))^-0.5
-4 * q^2 * (q^2 - (a^2/b^2))^0.5) * cosh((q^2 - (a^2/p_1^2))^0.5) * h
+ (r_1/r_2) * (q^2 - (a^2/p_1^2))^-0.5 * sinh((q^2 - (a^2/p_1^2))^0.5) * h
and q is unknown. I tried the following to solve F,
b = 2800;
a = 0.2 * 2 * pi;
p_1 = 1400;
p_2 = sqrt(3*b);
r_1 = 100000;
r_2 = 250000;
m = 1;
d = 100;
h = 4000;
F=@(q)(b/a)^4 * ((2*q^2 - (a^2/b^2))^2 * (q^2 - (a^2/p_2^2))^-0.5 ...
-4 * q^2 * (q^2 - (a^2/b^2))^0.5) * cosh((q^2 - (a^2/p_1^2))^0.5) * h ...
+ (r_1/r_2) * (q^2 - (a^2/p_1^2))^-0.5 * sinh((q^2 - (a^2/p_1^2))^0.5) * h;
z0=[-10 10];
sol=fzero(F,z0); % the solution is in region ??
but it gives an error relating to the region,
Error using fzero (line 274)
The function values at the interval endpoints must differ in sign.
Does anyone know how to deal with such an equation or have an alternative way to plot Cm?

5 comentarios

John D'Errico
John D'Errico el 20 de Mayo de 2016
Why not try plotting your function F?
ezplot(F,[-10,10]),grid on
ezplot(F,[-5,5]),grid on
ezplot(F,[-1,1]),grid on
ezplot(F,[-.1,.1]),grid on
Think about what you see. Does F ever cross zero?
Roger Stafford
Roger Stafford el 20 de Mayo de 2016
There appears to be a serious disconnect between the first part of your stated problem and the latter part. Up to the part where the variable F is defined as a function of the variable q and certain parameters, the problem seems to be one of making a plot of Cm as a function defined in terms of q and the derivative of F with respect to q. This would seem to be quite straightforward.
However, with the line
and q is unknown. I tried the following to solve F”
the problem suddenly becomes one of solving an equation using ‘fzero’. The two parts do not appear to be related to one another. What has plotting Cm in terms of the derivative of F with respect to q, got to do with the problem of finding the values of q for which the variable F is zero?
Perhaps you are trying to determine where the derivative of Cm is zero, but that is certainly not what your code is attempting to accomplish.
I think you had better think more carefully about which problem you wish to solve. To deepen the mystery, you define a quantity ’d’ which does not seem to ever be used. Is it possible you have confused the derivative, dF/dq, with an operation involving a numerical quantity d = 100?
John D'Errico
John D'Errico el 20 de Mayo de 2016
Yes, I wondered that myself, which is a big reason I did not pose my comment as an answer.
David
David el 20 de Mayo de 2016
The goal is to plot Cm. I tried diff(F, q) for the denominator but got an error saying q was undefined so I tried to solve the equation. If there is an easier way to plot Cm that would be good also. The "deep" mystery of d=100 is simply because I cut and paste the code block from my editor which has some other stuff going on not relevant to the question.
Roger Stafford
Roger Stafford el 20 de Mayo de 2016
If you wish to find the derivative of the function F with respect to q using matlab, rather than doing it by hand, then you need to use the symbolic form of the function where all the variables are properly defined as symbolic. Then to do plotting you need to convert this answer back to numerical quantities again. In any event, it makes absolutely no sense attempting to find roots of an equation F(q) = 0 as a substitute for this procedure.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Mayo de 2016

Comentada:

el 20 de Mayo de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by