Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How can I plug a solution from an equation back into another endlessly?

Asked by matlabuser12 on 3 Apr 2014
Latest activity Answered by Image Analyst on 3 Apr 2014

I have two equations, for example:

A=x+yz+B
B=l+p-A

assuming everything but A and B are constants, and I know an initial A or B (so I can get one solution) how can I take that answer and plug it in for the next solution, and iterate through solutions until either zero or set amount of solutions has occurred?

1 Comment

A Jenkins on 3 Apr 2014

What have you tried?

matlabuser12

Tags

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst on 3 Apr 2014

Try a while loop:

A=1
B=1
x=2
y=3
z=4
l=6
p=7
tolerance = 9999999
loopCounter = 1; % Failsafe - max # loops.
while tolerance > 0.1 && loopCounter < 100
	A=x+y*z+B
	B=l+p-A
	tolerance = abs(A) % Whatever ending condition you want.
	loopCounter = loopCounter + 1;
end

0 Comments

Image Analyst

Contact us