Looping output values back as input

I'm pretty new to matlab and (programming in general). I've written a program that inputs 3 points' coordinates (assuming them to be circle centers) and outputs tangent point coordinates between those circles. My question is: how can I make the program take the output tangent points and run them back in as new inputs for a certain number of iterations? I'm sure I need to use a loop, but I'm not sure how to use it for this particular purpose.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 11월 22일

0 개 추천

InputValue=1;
for k=1:NumberOfIteration
OutputValue=MyFunction(InputValue);
InputValue=MyFunction(OutputValue);
end

댓글 수: 4

Alex
Alex 2011년 11월 22일
Oh I see. Thank you. Would you happen to know how to handle the case where the output is conditional - for instance: if the slope between 2 points is infinite, the program handles that one way to produce the tangent point, but if it's not, it handles it another way.
Fangjun Jiang
Fangjun Jiang 2011년 11월 22일
I am not clear about your question. Do you mean if-else statement? Type "help if" to see an example.
Alex
Alex 2011년 11월 25일
Yes, an if-else. For instance, if the slope between 2 points is infinite, the tangent point outputted can't be calculated normally because the infinity term causes the expression to blow up, but otherwise it can be calculated normally.
Fangjun Jiang
Fangjun Jiang 2011년 11월 25일
So, what is your question. You don't know how to use if-else statement in MATLAB?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2011년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by