필터 지우기
필터 지우기

graphing 2 variables in one equation (can not be transposed)

조회 수: 1 (최근 30일)
Eli Kroitor
Eli Kroitor 2015년 5월 27일
댓글: Walter Roberson 2015년 5월 27일
Hi i would like to plot c in terms of k in this equation.... X=Y*sqrt((k^2+(c*w)^2)/(((k-m*w^2)^2+(c*w)^2)))
I know all the values except for C and K so really im trying to do a simple 2D x-y plane graph, but cannot do so easily because I can not (or do not know how to) express k in terms of c or vice versa so that i can use the ezplot command or something similar, Ive been racking my brain over this for a few days now, trying different ways, different commands and they all give me some sort of error.
note that... m=2000 ; Y=0.2 ; w=157.08 ; X=0.1 ; ANY HELP WILL BE GREATLY APPRECIATED thank you

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 27일
Square both sides to get rid of the sqrt(). Then multiply both sides by the denominator of the right hand side, to get two polynomials equal to each other. Distribute the Y^2 (that used to be Y but you squared) over the (k^2+(c*w)^2) to get Y^2*k^2 + Y^2*c^2*w^2 . Now you have c^2 times coefficients on each side, so subtract the Y^2*c^2*w^2 from both sides so that you end up with all the c^2 on the left and nothing in c on the right. Now you have of the form something1 * c^2 + something2 = something3 and that is clearly a quadratic so proceed to solve it: re-arrange to something1 * c^2 = something3 - something2, then divide through by the something1 to get c^2 = (something3 - something2) / something1 . Square root both sides, remembering to take both negative and positive square roots, and you have c in terms of +/- sqrt(an expression). Remember to plot both roots.
c1 = sqrt(-((X.^2 - Y.^2) .* (m.^2 .* w.^4 .* X.^2 - 2 .* k .* m .* w .^2 .* X.^2 + k.^2 .* X.^2 - k.^2 .* Y.^2))) ./ (w.*(X.^2 - Y.^2));
c = [c1(:),-c1(:)];
plot(k, c);
  댓글 수: 2
Eli Kroitor
Eli Kroitor 2015년 5월 27일
thank you very much for the replies Murali and Walter, I have successfully graphed k against c with your help, I dont know why I thought the equation was untransposable, I guess I just had a brain plug haha :p
Just out of curiosity, can Matlab transpose the equation for you to get one letter in terms of the other for you? cause that would be really helpful to limit any human error
Walter Roberson
Walter Roberson 2015년 5월 27일
If you have the Symbolic Toolbox then you can solve() the expression. For example,
syms X Y k c w m
solve( X==Y*sqrt((k^2+(c*w)^2)/(((k-m*w^2)^2+(c*w)^2))), c)

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

추가 답변 (1개)

Murali Krishna
Murali Krishna 2015년 5월 27일
try this.. create a function
function z = myfun(k,c)
m=2000 ; Y=0.2 ; w=157.08 ; X=0.1;
z = -X+Y*sqrt((k^2+(c*w)^2)/(((k-m*w^2)^2+(c*w)^2)));
end
ezplot(@(k,c)myfun(k,c),[kmin,kmax,cmin,cmax]) in mfile..
  댓글 수: 1
Eli Kroitor
Eli Kroitor 2015년 5월 27일
thank you very much for the replies Murali and Walter, I have successfully graphed k against c with your help, I dont know why I thought the equation was untransposable, I guess I just had a brain plug haha :p
Just out of curiosity, can Matlab transpose the equation for you to get one letter in terms of the other for you? cause that would be really helpful to limit any human error

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by