Storing Outputs of a two output function recursion

2 ビュー (過去 30 日間)
farah fadel
farah fadel 2020 年 3 月 25 日
編集済み: farah fadel 2020 年 3 月 26 日
Is there a method where I can apply a function with two outputs, and iterate the function recursively for these two outputs. In other words, I want this function to be applied on both outputs of this function until satisfying a condition(in a while loop),
UPDATE:I tried the recursion provided here by Image analyst ,https://www.mathworks.com/matlabcentral/answers/47182-problem-in-recursive-function, it worked well, but I want to keep storing all the outputs in 1 cell structure, is it possible?
  1 件のコメント
farah fadel
farah fadel 2020 年 3 月 25 日
I tried the answer provided here by Image analyst ,https://www.mathworks.com/matlabcentral/answers/47182-problem-in-recursive-function, it worked well, but I want to keep storing all the outputs in 1 cell structure, is it possible

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 3 月 25 日
Yes. There is no limitation on the number of outputs for recursive function.
  4 件のコメント
farah fadel
farah fadel 2020 年 3 月 25 日
編集済み: farah fadel 2020 年 3 月 25 日
no I want to store all the outputs coming of the recursion function. In each iteration of the recursive function, the two outputs should be stored in an cell structure containing all previous otputs too.
Fangjun Jiang
Fangjun Jiang 2020 年 3 月 25 日
Then it is not really an issue related to recursion. It is just storing data. The only thing to take care of is to declare a big enough arry or cell because the number of iteration is not determined. You can remove the un-used array space at the end.
x=100;y=200;
k=0;
result=ones(100,2);
while x>1e-3 && y>1e-4
k=k+1
[x,y]=D23(x,y);
result(k,:)=[x,y];
end
result(k+1:end,:)=[]
function [x,y]=D23(x,y)
x=x/2;
y=y/3;
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by