Plot a complicated equation

조회 수: 8 (최근 30일)
David
David 2016년 5월 20일
댓글: Roger Stafford 2016년 5월 20일
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
David
David 2016년 5월 20일
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 2016년 5월 20일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by