I wish to continously reuse the outputs generated from a previous function as inputs to subsequent functions. My aim is to produce a chained function ouput. What is the best or most effecient way to generate an overal output 'y_0_n' as seen below from an chained functional output in MATLAB.
x_0 = [1:10];
x_1 = Varx_1*func1(x_0);
x_2 = Varx_2*func1(x_1);
x_3 = Varx_3*func1(x_2);
% ................
x_n = Varx_n_1*func1(x_n_1);
y_0_n = Vary_n_1*func2([x_0;x_1;x_2;x_3;x_4;....x_n-1])

댓글 수: 3

Matt J
Matt J 2021년 3월 25일
That entirely depends on func1.
maubars
maubars 2021년 3월 25일
Two function actually, functions 1 generates linked concated outputs for fuction 2.
KSSV
KSSV 2021년 3월 25일
Go for a loop...

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

 채택된 답변

KSSV
KSSV 2021년 3월 25일

1 개 추천

You may proceed something like this:
x0 = 1:10 ;
n = 10 ; % number of times the function func1 to be called
var = rand(n,1) ; % your variables. I assume n and length of var is same as you have shown
m = value ; % length ofoutput of func1
X = zeros(n+1,m) ; % where m is output length of func1
X(1,:) = x0 ;
for i = 2:n+1
X(i,:) = var(i-1)*func1(X(i-1,:)) ;
end
y = vary*func2(X) ;

댓글 수: 3

maubars
maubars 2021년 3월 25일
Thanks. That works fine. Just a quick query. Is it possible to do the same with a mesh?
KSSV
KSSV 2021년 3월 25일
Very much possible......
maubars
maubars 2021년 3월 25일
Thanks. I will try it out on a mesh.

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2020b

질문:

2021년 3월 25일

댓글:

2021년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by