Functions

15 visualizzazioni (ultimi 30 giorni)
Milos Ivankovic
Milos Ivankovic il 16 Nov 2011
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 .

Risposte (2)

John D'Errico
John D'Errico il 16 Nov 2011
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 Commento
Milos Ivankovic
Milos Ivankovic il 16 Nov 2011
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 ?

Accedi per commentare.


Kai Gehrs
Kai Gehrs il 18 Nov 2011
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 Commenti
Milos Ivankovic
Milos Ivankovic il 18 Nov 2011
Kai you're a life saver :) Thank you so much
Oleg Komarov
Oleg Komarov il 28 Feb 2012
If you think he answered your question, accept his answer, it will be beneficial to others with same queries.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by