Answer:
% here x and y is given which we can take as
x = 2:2:10;
y = 2:2:10;
% creating a matrix of the points
point_matrix = [x;y];
% center point of rotation which is 2,2 here
x_center_pt = x(2);
y_center_pt = y(2);
% creating a matrix of the center point
center_matrix = repmat([x_center_pt; y_center_pt], 1, length(x));
% rotation matrix with rotation degree which is 45 degree
rot_degree = pi/4;
Rotate_matrix = [cos(rot_degree) -sin(rot_degree); sin(rot_degree) cos(rot_degree)];
% shifting points for the center of rotation to be at the origin
new_matrix = point_matrix - center_matrix;
% appling rotation
new_matrix1 = Rotate_matrix*new_matrix;
Explanation:
We start the program by taking vector of the point given to us and create a matrix by adding a scaler to each units with repmat at te center point which is (2,2). Then we find the rotation matrix by taking the roatational degree which is 45 given to us. After that we shift the points to the origin and then apply rotation ans store it in a new matrix called new_matrix1.
Answer:
ArrayList a contains [2, 3, 3, 3, 4, 5, 3, 2, 1]
Explanation:
Given
The removeValue method
Required
The content of ArrayList a, after the method is called
From the question, we understand that arraylist a is:
The function fails when the value to be removed appear consecutively in the list.
4 appears in index 5 and 6 of the list. Only one of the 4's will be removed
So, the updated list will be: [2, 3, 3, 3, 4, 5, 3, 2, 1]
Answer:
player1Wins = player1Losses = player2Wins = player2Losses = tieCount = 0
score1 = 10
score2 = 10
if score1>score2:
player1Wins=player1Wins+1
player2Losses=player2Losses+1
print("player1 wins")
elif score2>score1:
player2Wins=player2Wins+1
player1Losses=player1Losses+1
print("player2 wins")
else:
tieCount=tieCount+1
print("tie")
Explanation:
Since your indentation can not be understand what you give us, please try to do it as you see in the answer part.
Although it seems that this is a part of the code, it is normal that you get errors. However, since you keep track of the variables, it is better to initialize the variables that will keep the counts. Since initially, they are 0, you may set them as 0. Also, if you assign the values to the scores, probably you would not get any error. This way, you may test your code as I did.
Other than these, in the else part you do not need to write "score1=score2", because if score1 is not greater than score2 and if score2 is not greater than score1, this already implies that they are equal
Answer:
I believe the answer is D. var = var + 1
Explanation: