필터 지우기
필터 지우기

problem with 'solve' function to solve a set of equations

조회 수: 1 (최근 30일)
Albert
Albert 2016년 10월 5일
댓글: Star Strider 2016년 10월 5일
Hi, everyone Is there anybody knowing how to solve issue of using 'solve' in matlab? I always have trouble using 'solve' in matlab. Here is a set of equations I am trying to solve with function 'solve' in matlab, but anyhow I can't get the desired result. In another word, matlab doesn't provide complete answers. Following is part of my code:
syms theta_A theta_B
p=-987614208*theta_A^24*theta_B^9*(theta_A - 1)^6*(theta_B - 1)^11;
[theta_A,theta_B]=solve('diff(P,theta_A)==0','diff(P,theta_B)==0','theta_A','theta_B');
The result that matlab gives is [0, 0];
I simple don't understand how this come. Because obviously theta_A=1 and theta_B=1 would satisfy the equations. Also there are more answers to be found.
Please help me out.
Greatly appreciate it!

채택된 답변

Star Strider
Star Strider 2016년 10월 5일
You didn’t say what MATLAB version you’re using. The single-quote syntax is no longer appropriate in R2016b.
Otherwise, know that MATLAB is case-sensitive, so p~=P. Changing that gives the sort of result you likely want:
syms theta_A theta_B
P=-987614208*theta_A^24*theta_B^9*(theta_A - 1)^6*(theta_B - 1)^11;
[theta_A,theta_B]=solve(diff(P,theta_A)==0,diff(P,theta_B)==0,[theta_A,theta_B]);
theta_A =
4/5
0
0
1
theta_B =
9/20
0
1
0
  댓글 수: 2
Albert
Albert 2016년 10월 5일
Thank you Star Strider very much. Sorry about the lower case p and capital case P, that's a mistake in the process of copying my code. The matlab I am using is 2016a. I updated my matlab several months ago. One in a while I have trouble doing what I successfully did before. It may be due to version update of matlab. Thank you again.
Star Strider
Star Strider 2016년 10월 5일
My pleasure.
Definitely read the Release Notes! They tell you the version difference syntax and functions. (I’m still reading the ones for R2016b.)
If you have R2016a, the problem was most likely the single-quotes, and not putting the variables you want to solve for in vector format (square brackets). Those changes gave the correct answer.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by