Matlab code required AArray 1 has 20 values B Array 2 has 21
 Matlab code required 
 
 
 
 
 
 
 
 
 [A]Array 1 has 20 values
 [B] Array 2 has 21 values
 I need to element by element do the following:
 A (1) - B (1)
 A (2) - B (2)
 And somehow be able to discount the last B value
 So my last calc will be
 A (20) - B (20)
 Using
 A for loop with storing values and a counter
  Matlab code required 
 
 
 
 
 
 
 
 
 [A]Array 1 has 20 values
 [B] Array 2 has 21 values
 I need to element by element do the following:
 A (1) - B (1)
 A (2) - B (2)
 And somehow be able to discount the last B value
 So my last calc will be
 A (20) - B (20)
 Using
 A for loop with storing values and a counter
 [A]Array 1 has 20 values
 [B] Array 2 has 21 values
 I need to element by element do the following:
 A (1) - B (1)
 A (2) - B (2)
 And somehow be able to discount the last B value
 So my last calc will be
 A (20) - B (20)
 Using
 A for loop with storing values and a counter
 Solution
Here is the code:
Remeber in matlab Arrays are two dimentioal, Vectors are single dimensional
% Here A with 20 values
A = [11 20 32 4 5 6 7 8 9 10 12 45 8 7 4 6 3 1 2 21];
% B with 21 values
 B = [11 20 32 4 5 6 7 7 9 10 12 45 8 7 4 6 3 1 2 20 12];
% A counter variable for arrays
count=1
% for loop for 21 times
 for i=1:21
% checking if it is 21 th iteration
 if i==21
% if true then breakig the loop
 break
% else calculating the value A(count)-B(count) then incrementing the counter variable
 else
 A(count)-B(count)
 count=count+1;
% End of if
 end
% End of for loop
 end
Ouput:
count =1
ans = 0
ans = 0
....
...
...
ans = 1
![Matlab code required [A]Array 1 has 20 values [B] Array 2 has 21 values I need to element by element do the following: A (1) - B (1) A (2) - B (2) And somehow   Matlab code required [A]Array 1 has 20 values [B] Array 2 has 21 values I need to element by element do the following: A (1) - B (1) A (2) - B (2) And somehow](/WebImages/31/matlab-code-required-aarray-1-has-20-values-b-array-2-has-21-1087862-1761572308-0.webp)
![Matlab code required [A]Array 1 has 20 values [B] Array 2 has 21 values I need to element by element do the following: A (1) - B (1) A (2) - B (2) And somehow   Matlab code required [A]Array 1 has 20 values [B] Array 2 has 21 values I need to element by element do the following: A (1) - B (1) A (2) - B (2) And somehow](/WebImages/31/matlab-code-required-aarray-1-has-20-values-b-array-2-has-21-1087862-1761572308-1.webp)
