Functions

1 回表示 (過去 30 日間)
Milos Ivankovic
Milos Ivankovic 2011 年 11 月 16 日
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 .

回答 (2 件)

John D'Errico
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.
  1 件のコメント
Milos Ivankovic
Milos Ivankovic 2011 年 11 月 16 日
Thx for your reply , i know math so i can solve it on my own , but i need a program to do it because it is part of a program that has "for" cycle of 1:100000 , those two equasions are the first data and i they will change during the "for" cycle . Sum(b) should look like this '1904.91-x+y' and sum(d) '2295.05+x-y' . I tried lots of tools but i keep doing something wrong and getting a mistake that says undefined function or varible 'x' , i tried 'inline' command and function file for example , but i am doing something wrong , got any other suggestion's ?

サインインしてコメントする。


Kai Gehrs
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 件のコメント
Milos Ivankovic
Milos Ivankovic 2011 年 11 月 18 日
Kai you're a life saver :) Thank you so much
Oleg Komarov
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 ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by