Need to Produce a different matrix after each loop
Afficher commentaires plus anciens
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 commentaires
Scott MacKenzie
le 25 Juin 2021
Modifié(e) : Scott MacKenzie
le 26 Juin 2021
It would help if you provide code that can be executed. As posted, the code accesses a few uninitialized variables.
It looks to me as if deli is indeed different after each for i loop. You do not ask to record the value for each i value though.
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=([]);
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
deli
mbar{i}=(kg{i}*deli)+fembar{i};
end
DARLINGTON ETAJE
le 28 Juin 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!