CREATING A LOOP FROM DATA
3 views (last 30 days)
Show older comments
Hi, i am wondering if anyone can help me create a loop for this data? I have typed it all out individually but was wondering how i go about creating a loop to condense it all down? Thanks in advance
A1= (B(:,1) - C(1))/ D(1)
A2 = (B(:,2) - C(2)) / D(2)
A3 = (B(:,3) - C(3)) / D(3)
A4 = (B(:,4) - C(4)) / D(4)
A5 = (B(:,5) - C(5)) / D(5)
A6 = (B(:,6) - C(6)) / D(6)
A7 = (B(:,7) - C(7)) / D(7)
A8 = (B(:,8) - C(8)) / D(8)
A9 = (B(:,9) - C(9)) / D(9)
A10 = (B(:,10) - C(10)) / D(10)
A11 = (B(:,11) - C(11)) / D(11)
A12 = (B(:,12) - C(12)) / D(12)
A13 = (B(:,13) - C(13)) / D(13)
A14 = (B(:,14) - C(14)) / D(14)
A15 = (B(:,15) - C(15)) / D(15)
A16 = (B(:,16) - C(16)) / D(16)
A17 = (B(:,17) - C(17)) / D(17)
A18 = (B(:,18) - C(18)) / D(18)
A19 = (B(:,19) - C(19)) / D(19)
A20 = (B(:,20) - C(20)) / D(20)
A21 = (B(:,21) - C(21)) / D(21)
A22 = (B(:,22) - C(22)) / D(22)
0 Comments
Answers (1)
Monika Jaskolka
on 16 Nov 2021
n = 22;
B = rand(10,n);
C = rand(n,1);
D = rand(n,1);
A = zeros(size(B));
for i = 1:n
A(:,i) = (B(:,i) - C(i))/ D(i);
end
2 Comments
Monika Jaskolka
on 16 Nov 2021
I chose it arbitrarily because you didn't provide your data. You can change it to suit your needs.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!