Difference between "diff(x^2)" and "2*x"
이전 댓글 표시
Hi, I can't figure out how are the following two situations different:
syms x1 x2 F;
U=x1^2+(x2-F)^2;
solve('diff(U,x1)=0','diff(U,x2)=0','x1,x2')
vs.
solve('2*x1=0','2*(x2-F)=0','x1,x2')
In the first case MATLAB can't find a solution, although it is a simple linear system (the same one as in the second case which works fine). Any ideas? Thank you:)
채택된 답변
추가 답변 (1개)
Wayne King
2012년 9월 19일
편집: Wayne King
2012년 9월 19일
syms x1 x2 F;
U=x1^2+(x2-F)^2;
sol = solve(diff(U,x1)==0,diff(U,x2)==0,x1,x2);
sol.x1
sol.x2
Identical for me to:
sol2 = solve(2*x1==0,2*(x2-F)==0,x1,x2);
sol2.x1
sol2.x2
댓글 수: 1
Jan commented:
Thanks for your answer, I should add that I'm using MATLAB R2010b and the syntax has changed, but that still doesn't explain this behavior to me. Your modified code
syms x1 x2 F;
U=x1^2+(x2-F)^2;
sol = solve('diff(U,x1)=0','diff(U,x2)=0','x1,x2')
sol.x1
sol.x2
still generates:
Warning: Could not extract individual solutions. Returning a MuPAD set object.
I will update to a recent version, because I'm almost certain that this is not due to a trivial mistake on my part (although it is possible of course). Thank you for any further comments!
카테고리
도움말 센터 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!