Functions
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi i need some help , i'm trying to create a script file and one part of it needs to calculate sum of these two values d=[210 628.65 1050-x y 16.26] and b=[0 1.33 x 840-y 1453.72] so that i can later use that sum to solve these two equasions by x and y : y/sum(b)=3/100 and x/sum(d)=1/100 . I would preffer if i didnt have to use function file but if it cant be done without one i can use it .
댓글 수: 0
답변 (2개)
John D'Errico
2011년 11월 16일
Can you write out what the sum of b and d are? Try it. Use pencil and paper here if you want.
Next, if sum(b) or sum(d) were zero, then you could not multiply by those quantities. But if that were true, then you could not have a finite ratio as a result. So it is safe to multiply by those quantities. You should probably verify the result at the end to ensure a singularity does not result anyway.
Having done that wee bit of algebra, can you write down the equations in a simple, standard form? Can you solve them by hand? If not, then there are tools that can do this in MATLAB. But just a bit more simple algebra on paper will suffice.
I would point out that it is never a good idea to rely so much on a computer program that you forget how to do simple algebra yourself (or never learn basic algebra at all.) So try it! If this is really a homework problem, then try using the symbolic toolbox. Or learn how backslash would be used to solve the problem in the end. But if it is homework, then I we should not be doing it for you anyway.
Kai Gehrs
2011년 11월 18일
Hi Milos,
I think using the Symbolic Math Toolbox is a good recommendation for the problem.
Here is what I would do in MATLAB (as far as I have understood you correctly):
>> syms x y;
>> d=[210 628.65 1050-x y 16.26];
>> b=[0 1.33 x 840-y 1453.72];
>> S = solve(y/sum(b)-3/100,x/sum(d)-1/100,x,y)
S =
x: [1x1 sym]
y: [1x1 sym]
>> S.x
ans =
634659/32500
>> S.y
ans =
547746/8125
Hope this helps and best regards,
-- Kai
댓글 수: 2
Oleg Komarov
2012년 2월 28일
If you think he answered your question, accept his answer, it will be beneficial to others with same queries.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!