Solving equation with symbolic vector variable
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I want to solve an equation of the form: V/(A-V)=B where A and B are known vectors and V is the symbolic vector variable I want to solve for. I created V by >>V=sym('V',[n 1]); and solved the equation by using 'solve' but in the output I get only the 'names' of the elements - V1, V2, V3, ... How do I get the values of V1, V2,...? Any help is much appreciated.
댓글 수: 2
Is the division to be matrix division, or element-by-element?
Element-by-element.
채택된 답변
Walter Roberson
2013년 11월 16일
V = B .* A ./ (B + 1);
댓글 수: 15
Sorry, I should have mentioned that in my equation, A and B are not simple vectors but functions of scalars and vectors, such that it is difficult to isolate V to the left hand side of the equation and everything else to the right hand side. That is the reason why I think I need to solve the equation symbolically (by creating a symbolic vector variable V).
If V were a simple symbolic variable (not vector), I think I know how to solve the equation symbolically. But I don't know how to handle symbolic VECTOR variables.
So V/(A-V)=B is not really the form you are using? Or is it just "expensive" to calculate A and B ?
Yeah, I thought solving it symbolically was the easiest way. I can solve it by calculating A and B, or using a for loop.
Could you show your solve() command ?
solve(Kgasa./(Kq-Kgasa)-Kg./(poro.*(Kq-Kg))==Kwsat./(Kq-Kwsat)-Kw./(poro.*(Kq-Kw)))
I need to solve for Kgasa. poro and Kwsat are the known vectors.
Which of those are intended to be numeric and which are intended to involve symbols? Are there any symbols present other that the V ? Are you assigning the output to anything?
Only Kgasa is a symbolic variable (vector). All the others are either scalars or vectors in my workspace. Actually, it's just a linear equation with one variable (Kgasa) which I want to solve for 10 different values of poro and Kwsat. I want the vector Kgasa to contain those 10 roots. The code runs well without any error, but instead of getting numerical values in Kgasa, I get the elements as Kgasa1, Kgasa2,... I dont know how to display their numeric values.
Kgasa = ((-Kwsat .* poro + Kw - Kg) .* Kq.^2 + Kwsat .* ((Kw + Kg) .* poro - Kw + Kg) .* Kq - Kwsat .* poro .* Kg .* Kw) ./ (-poro .* Kq.^2 + ((Kw + Kg) .* poro + Kw - Kg) * Kq + (Kg - Kw) .* Kwsat - poro .* Kg .* Kw)
Wow, you did some hard work. :) I was too lazy to do that. Now I dont need to use a symbolic variable. Thanks a lot.
I simply used a symbolic package. The hard work was in editing the text to space it nicely and to add all of the "." in appropriate places ;-)
Well, got the same problem, only I cannot avoid using symbolic variables. And here on top of google search quiery we have an 'accepted' answer that DOESN'T ANSWER THE GODDAMN QUESTION. Shame on your face. If you are content with people doing your job for you, however not connected with the question you've asked, would you please go to some other forum.
Alexander Kharlan:
V = B .* A ./ (B + 1)
is the solution to the question originally presented. It turned out that question originally presented was not the real question, and the real question was solved to the user's satisfaction.
The more general question of how to solve a symbolic vector equation depends upon the release you are using . In current releases, you just use solve() on the vector equation. In slightly older releases, you use num2cell() to break the vector up into a cell array, and then you use cell array expansion to push the elements as separate parameters to solve(). For example,
mveq = num2cell(myVectorOfEquations);
mvvar = num2cell(VariablesToSolveFor);
solve(mveq{:}, mvvar{:})
"If you are content with people doing your job for you"
Answering questions here is not my job. As far as I know, the only people who are paid to answer questions here are the Mathworks staff who work on the Answers forum software itself. Everyone else who answers questions here (including the other people who happen to work for Mathworks) does so as a volunteer. I do not work for Mathworks; I have never worked for Mathworks.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
