Functions
2 次查看(过去 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!