MATLAB Answers

How to do iteration?

1 view (last 30 days)
Jenjen Ahmad Zaeni
Jenjen Ahmad Zaeni on 15 Jun 2021
Commented: KSSV on 15 Jun 2021
Hello everyone, i currently work in decoding. I want to do box-plus operation so i wrote a code like
Lch=[-22.5971212295960 29.9076428426283 -17.3150512249935 16.1986770081474 -29.0533677411566 39.4388257818327 -23.4478195797575 6.76446399877276 -26.0589329667166 -22.8633655415058 -19.1520108645588 -17.3602541863574 -9.22984377804479 10.5858389093068 26.2837278083571 -33.1287682024654 -21.1153772829181 10.9787413317923 24.1988157343676 -20.8766135548397 21.2872175079274 -19.0552409679792 30.9733304312483 -18.0747532073568 22.5658114310165 18.0772293396035 -18.3028464245073 -15.7544695879375 -24.9178556220618 -5.33973720315673 26.5625280333299 8.53699135029120 22.0212716020991 12.4585490324220 12.1197779296794 21.0867954596413 -9.23553272601253 25.4641237681280 -14.8196806409561 23.3519941628122 -27.9100606340587 -14.9544971751005 -20.6397114690034 -13.6098146399727 23.1424682033231 -24.6572397730130 14.9696105463177 -17.5593793136306 -19.1881132404073 21.0276728693089 27.5734626431655 -22.8698188987151 5.46174151424931 -12.7131223953086 22.5730660185771 -16.4538735536458 -24.0906068730404 21.2563122055076 20.4515304665018 -25.8859806515697 -20.9291339670982 9.77714444450563 -16.8917501411585 17.7346216213321 16.2217521727836 -19.1740741431189 19.3082463062482 -21.4106053109496 -17.3835567083056 17.3624930665649 -18.0527363621446 25.5555071828869 15.9750378948005 23.5427851388678 16.1520202473211 19.0810883976484 -24.9290847628849 -10.1987964316783 18.6554176502525 16.0952969710241 -14.7225043347871 26.1991465864214 9.82729631878485 -25.7180350652549 15.5324715245736 -16.7870087059569 14.7998144843216 -16.7333495681869 11.6088435069176 -16.6837508703570 -25.6385359132979 14.9157566455187 -20.6479301511260 -20.1142686297330 18.0592193715814 21.3868659949060 -28.1303041246514 -16.5319437806921 -17.7151132424342 -14.9653396773181]
for ii = 1:25
La = Lch(1+(ii-1)*4:ii*4); % Select every 4 data
for L = 1:4
% Box Plus Operation
Le=sign(prod(La(setdiff(1:end, L))))*min(abs(La(setdiff(1:end, L))));
Lq{L}=Le;
end
Lr=horzcat(Lq{:});
Ln{ii}=Lr;
end
Lz=horzcat(Ln{:});
I want to do this operation for 4 times, what should i do to make the final value of Lz to being processed again like before? Thank you very much.

Answers (1)

KSSV
KSSV on 15 Jun 2021
Lch=[-22.5971212295960 29.9076428426283 -17.3150512249935 16.1986770081474 -29.0533677411566 39.4388257818327 -23.4478195797575 6.76446399877276 -26.0589329667166 -22.8633655415058 -19.1520108645588 -17.3602541863574 -9.22984377804479 10.5858389093068 26.2837278083571 -33.1287682024654 -21.1153772829181 10.9787413317923 24.1988157343676 -20.8766135548397 21.2872175079274 -19.0552409679792 30.9733304312483 -18.0747532073568 22.5658114310165 18.0772293396035 -18.3028464245073 -15.7544695879375 -24.9178556220618 -5.33973720315673 26.5625280333299 8.53699135029120 22.0212716020991 12.4585490324220 12.1197779296794 21.0867954596413 -9.23553272601253 25.4641237681280 -14.8196806409561 23.3519941628122 -27.9100606340587 -14.9544971751005 -20.6397114690034 -13.6098146399727 23.1424682033231 -24.6572397730130 14.9696105463177 -17.5593793136306 -19.1881132404073 21.0276728693089 27.5734626431655 -22.8698188987151 5.46174151424931 -12.7131223953086 22.5730660185771 -16.4538735536458 -24.0906068730404 21.2563122055076 20.4515304665018 -25.8859806515697 -20.9291339670982 9.77714444450563 -16.8917501411585 17.7346216213321 16.2217521727836 -19.1740741431189 19.3082463062482 -21.4106053109496 -17.3835567083056 17.3624930665649 -18.0527363621446 25.5555071828869 15.9750378948005 23.5427851388678 16.1520202473211 19.0810883976484 -24.9290847628849 -10.1987964316783 18.6554176502525 16.0952969710241 -14.7225043347871 26.1991465864214 9.82729631878485 -25.7180350652549 15.5324715245736 -16.7870087059569 14.7998144843216 -16.7333495681869 11.6088435069176 -16.6837508703570 -25.6385359132979 14.9157566455187 -20.6479301511260 -20.1142686297330 18.0592193715814 21.3868659949060 -28.1303041246514 -16.5319437806921 -17.7151132424342 -14.9653396773181] ;
for i = 1:4
Ln = cell(1,25) ;
for ii = 1:25
La = Lch(1+(ii-1)*4:ii*4); % Select every 4 data
Lr = zeros(1,4) ;
for L = 1:4
% Box Plus Operation
Le=sign(prod(La(setdiff(1:end, L))))*min(abs(La(setdiff(1:end, L))));
Lr(L)=Le;
end
Ln{ii}=Lr;
end
Lz=horzcat(Ln{:});
Lcz = Lz ;
end
  2 Comments
KSSV
KSSV on 15 Jun 2021
i do to make the final value of Lz to being processed again like before..
You wanted to use Lz again right?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!