필터 지우기
필터 지우기

Functions

조회 수: 3 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by