Borrar filtros
Borrar filtros

How to flip in specific rows in an array with a for loop

1 visualización (últimos 30 días)
Isha Punn
Isha Punn el 8 de Oct. de 2017
Comentada: Isha Punn el 8 de Oct. de 2017
I'm trying to flip a row based on its left and right maximum values and obtain an array with all these changes.
[leftMAX,left_idx]=max(leftA,[],2);
[rightMAX, right_idx]=max(rightA,[],2);
[middleMAX, middle_idx]=max(middleA,[],2);
n= size(A,1);
for ii = 1:n-1
if leftMAX> rightMAX
continue
elseif rightMAX>leftMAX
fliplr(A(n,:))
end
end
However nothing changes in the array A

Respuestas (1)

Walter Roberson
Walter Roberson el 8 de Oct. de 2017
fliplr(A(n,:))
executes the fliplr. Then, there is no assignment statement, so it assigns the value to the variable "ans". It then looks and sees that there is no semi-colon after the expression, so it displays the value of the variable ans.
You did not make any change to the variable A.
  1 comentario
Isha Punn
Isha Punn el 8 de Oct. de 2017
So then how can I display the all the changes within another array without losing other data?

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by