필터 지우기
필터 지우기

How to create dynamic for loop according to indices in multidementional cell

조회 수: 1 (최근 30일)
Akram RAYRI
Akram RAYRI 2022년 6월 15일
편집: Akram RAYRI 2022년 6월 15일
Hi guys, I have a serious problem here :
hw1 = 0;
bs = 5;
ue = 8;
s = 16;
for k = 1:ue
for i = 1:ue
if i~=k
for i1 = 1:s
for i2 =1:s
.
.
.
for in = 1:s
for l = 1:bs
hw1 = hw1 + H{l,k}*Wli{l,i,i1,i2,..in};
end
sum_hw1{l,i,i1,i2,i3...,in} = hw1;
hw1 = zeros(u,1);
end
.
.
.
end
end
end
end
end
The question is the following : how should I create dynimacally a number of "bs" for loops and also how to create accordinally number of indices in "Wli" cell so that I will store each value of "hw1" in "sum_hw1". Hope that you have a solution for this issue !
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 6월 15일
https://www.mathworks.com/matlabcentral/answers/?search_origin=ans_leaf&term=tag%3Aodometer has source in a couple of responses
Akram RAYRI
Akram RAYRI 2022년 6월 15일
편집: Akram RAYRI 2022년 6월 15일
Thank's Walter for your feedback. As far as I understood, this chunk of code is my solution !
According to the shared link.
Var = cell(n, 1);
[Var{1:n}] = ndgrid(1:k);
y = f(Var{:});

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by