Need to Produce a different matrix after each loop

조회 수: 1(최근 30일)
DARLINGTON ETAJE
DARLINGTON ETAJE 2021년 6월 25일
댓글: DARLINGTON ETAJE 2021년 7월 7일
Hello Friends,
I need to produce a different set of deli after each loop but it remains the same. Help me out please...see code below.
deli is suppose to be different set of 12 by 1 after each loop
L1=[1 33 34 2 35 36 3 37 38 4 39 40];
L2=[3 37 38 4 39 40 5 41 42 6 43 44];
L3=[5 41 42 6 43 44 7 45 46 8 47 48];
L4=[7 45 46 8 47 48 9 49 50 10 51 52];
L5=[9 49 50 10 51 52 11 53 54 12 55 56];
L6=[11 53 54 12 55 56 13 57 58 14 59 60];
L7=[13 57 58 14 59 60 15 61 62 16 63 64];
L8=[15 61 62 16 63 64 17 65 66 18 67 68];
L9=[17 65 66 18 67 68 19 69 70 20 71 72];
L10=[19 69 70 20 71 72 21 22 23 24 25 26];
L11=[21 22 23 24 25 26 27 28 29 30 31 32];
L=[L1;L2;L3;L4;L5;L6;L7;L8;L9;L10;L11];
delu=[-107.9277784;-473.7489066;-456.4464814;-298.1506906;-38.38102414;169.6616599;218.8447121;105.0260144;-78.47051372;-205.707;-1.1961463;701.7499816;-2084.55571;-1229.851404;-0.390010302;39.67805573;-68.88297022;2231.216584;-5473.430599;-3189.887351;-0.390010302;41.85037402;-72.64553587];
delr=zeros(49,1);
del=[delu;delr];
deli=zeros(12,1);
delbar=([]);
mbar=repmat({zeros(12,1)},n,1);
for i=1:n
for p=1:12
deli(p,1)=del((L(i,p)),1);
end
mbar{i}=(kg{i}*deli)+fembar{i};
end
  댓글 수: 3
DARLINGTON ETAJE
DARLINGTON ETAJE 2021년 6월 28일
Thank you so much.

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

채택된 답변

Jayant Gangwar
Jayant Gangwar 2021년 7월 7일
It is my understanding that you want to produce and store the set of deli after each iteration. In your current code the deli produced after each set is correct you just need to store it as well after each iteration. In the code below each column of delstore represents the set of deli after the corresponding iteration.
L1=[1 33 34 2 35 36 3 37 38 4 39 40];
L2=[3 37 38 4 39 40 5 41 42 6 43 44];
L3=[5 41 42 6 43 44 7 45 46 8 47 48];
L4=[7 45 46 8 47 48 9 49 50 10 51 52];
L5=[9 49 50 10 51 52 11 53 54 12 55 56];
L6=[11 53 54 12 55 56 13 57 58 14 59 60];
L7=[13 57 58 14 59 60 15 61 62 16 63 64];
L8=[15 61 62 16 63 64 17 65 66 18 67 68];
L9=[17 65 66 18 67 68 19 69 70 20 71 72];
L10=[19 69 70 20 71 72 21 22 23 24 25 26];
L11=[21 22 23 24 25 26 27 28 29 30 31 32];
L=[L1;L2;L3;L4;L5;L6;L7;L8;L9;L10;L11];
delu=[-107.9277784;-473.7489066;-456.4464814;-298.1506906;-38.38102414;169.6616599;218.8447121;105.0260144;-78.47051372;-205.707;-1.1961463;701.7499816;-2084.55571;-1229.851404;-0.390010302;39.67805573;-68.88297022;2231.216584;-5473.430599;-3189.887351;-0.390010302;41.85037402;-72.64553587];
delr=zeros(49,1);
del=[delu;delr];
deli=zeros(12,1);
delbar=([]);
delstore=[];
n = 2; kg = {3;5}; fembar = {2; 103};
mbar=repmat({zeros(12,1)},n,1);
for i=1:n
for p=1:12
deli(p,1)=del((L(i,p)),1);
end
delstore=[delstore,deli];
mbar{i}=(kg{i}*deli)+fembar{i};
end

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by