symbolic variable not recognized

조회 수: 11 (최근 30일)
Mohammad Moeid Elahikahooker
Mohammad Moeid Elahikahooker 2018년 10월 1일
Hi MATLAB world!
I have a weird problem. I have defined 4 symbolic variables (kL, kR, kTR, kTL) for my code. I use these variables in different matrices and find their determinants with no problem.
I then have defined another variable in which I do a algebraic symbolic expression (by that I mean it includes few multiplications and additions and powers)and all of a sudden it does not recognize these variables. I have a variable lambda in there as well and it has no problem with that.
here is the error I get:
Undefined function or variable 'k'.
Error in Eoperator (line 169)
if I define k as a symbol, then it ruins my calculation but does not solve the problem either, it tells me that TL and TR and L and R are undefined.
What am I supposed to do?
Thank you all for your time and help in advance.
  댓글 수: 5
Mohammad Moeid Elahikahooker
Mohammad Moeid Elahikahooker 2018년 10월 1일
Hi Stephen,
Sorry for the confusion, this is actually my second iteration of the code. I tried to remove the underscore from my variables in hopes that it will help.
So I redefined k_L as kL for example and used that.
As you can see in the code, I have defined all the variables I am using and I am still getting the error.
Torsten
Torsten 2018년 10월 1일
And what's the error message now ?

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

채택된 답변

Stephan
Stephan 2018년 10월 1일
편집: Stephan 2018년 10월 1일
Hi,
look at the second line of paper_det - your code:
lambda^4-kL*k*TL
since there is not k and not TL defined in your code, but kTL is, i would bet, that it should be:
lambda^4-kL*kTL
which is the same structure of the calculation as the other parts of paper_det. Then the code runs without error - so it was just a typo(?)
paper_det=((lambda^4)+kL*kTL)*((lambda^4)+kR*kTR )-2*(lambda^2)*((lambda^4)*kTR *kTL-kL*kR)*sinh(lambda)*sin(lambda)...
+(2*lambda^4*(kL*kTR +kR*kTL)-(lambda^4-kL*kTL)*(lambda^4-kR*kTR ))*cosh(lambda)*cos(lambda)...
-lambda*((lambda^4-kL*kTL)*(lambda^2*kTR +kR)+(lambda^4-kR*kTR )*(lambda^2*kTL+kL))*sin(lambda)*cosh(lambda)...
-lambda*((lambda^4-kL*kTL)*(lambda^2*kTR -kR)+(lambda^4-kR*kTR )*(lambda^2*kTL-kL))*cos(lambda)*sinh(lambda)
Best regards
Stephan
  댓글 수: 1
Mohammad Moeid Elahikahooker
Mohammad Moeid Elahikahooker 2018년 10월 2일
Thanks Stephan,
days of working on multiple codes in a rush for a paper had blinded me to that mistake.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by