Fliplr and flipud functions no longer accepts vectors
Mostrar comentarios más antiguos
Fliplr and flipud functions does not accept vectors in R2010bsp1. Don't know when (or why) this change was introduced, but finding out exactly why my old code won't work anymore is pretty straightforward:
My old matlab (r2007b) uses if(ndims(x)~=2) to determine if the inputs to flipud/fliplr is valid, which works fine for vectors (1-by-n or n-by-1 arrays). R2010b uses ~ismatrix(x), which requires that x must be of size n-by-m (where m,n>1). And yes, these are elementary matlab functions located in toolbox\matlab\elmat\ ... no obvious reason to change those, I would think.
The documentation is NOT updated - I quote from doc fliplr: If A is a row vector, then fliplr(A) returns a vector of the same length with the order of its elements reversed. If A is a column vector, then fliplr(A) simply returns A. Clearly, this is no longer correct.
My question: Why on earth was this change made????
It has made A LOT of my code incompatible with r2010b. I can't be the only one who has experienced this?
2 comentarios
Walter Roberson
el 22 de Mzo. de 2011
By the way, this exact same issue came up for someone in the discussion area, sometime around mid December; the solution was exactly the same, that they had a conflicting routine in their path.
MarionJ
el 31 de Jul. de 2018
I have exactly the same Problem. I have a 92 x 3 double Matrix and fliplr has no effect. ISMATRIX returns however the value '1'. What did you change to make it work?
Respuesta aceptada
Más respuestas (3)
Matt Tearle
el 22 de Mzo. de 2011
ismatrix is true for a vector or even a scalar -- everything in MATLAB is a matrix unless you force it not to be (eg a 3-D array). Have you actually tested flipud on vectors? This works fine for me in both R2010b and R2011a:
x = 1:5
fliplr(x)
flipud(x)
flipud(x')
fliplr(x')
>> which ismatrix
built-in (C:\Program Files\MATLAB\R2010b\toolbox\matlab\elmat\ismatrix)
>> which flipud
C:\Program Files\MATLAB\R2010b\toolbox\matlab\elmat\flipud.m
>> which fliplr
C:\Program Files\MATLAB\R2010b\toolbox\matlab\elmat\fliplr.m
Jan Jensen
el 22 de Mzo. de 2011
0 votos
John D'Errico
el 22 de Mzo. de 2011
This is surely the expected behavior of these tools.
>> flipud(1:5)
ans =
1 2 3 4 5
applied to a row vector, flipud should be a no-op, returning the input vector unchanged. Of course, fliplr does reverse the order.
>> fliplr(1:5)
ans =
5 4 3 2 1
The above test was performed in both R2010b and in the prerelease R2011 version, with no problems found. So I'm not sure what the issue is here, unless you are indeed using a non-standard form of ismatrix.
2 comentarios
Jan Jensen
el 22 de Mzo. de 2011
Matt Fig
el 22 de Mzo. de 2011
As was indicated in Jan's Answer...
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!