Clear Filters
Clear Filters

Fliplr and flipud functions no longer accepts vectors

4 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 22 Mar 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
MarionJ on 31 Jul 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?

Sign in to comment.

Accepted Answer

Matt Fig
Matt Fig on 22 Mar 2011
According to the documentation, ISMATRIX returns true if size(A) is [m,n] for non-negative m,n. Thus a vector should return true. I suspect the problem lies elsewhere.
Is the ISMATRIX an M-file or a built-in? If it is an M-file, could you check the code to verify the doc is correct?
I noticed there is an ISMATRIX on the FEX, are you sure you aren't using a custom version? Will you also check that you are not using a custom FLIPLR?

More Answers (3)

Matt Tearle
Matt Tearle on 22 Mar 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
Jan Jensen on 22 Mar 2011
Thanks Matt and Matt - and yes, the deviation from normal everything is a matrice - behavior certainly is puzzling, isn't it?
The problem was in another library that had its own version of ismatrix which didn't accept vectors as valid matrices.
Thanks for putting me on the right track - I wouldn't have checked that without your input.

John D'Errico
John D'Errico on 22 Mar 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 Comments
Jan Jensen
Jan Jensen on 22 Mar 2011
Correct, the problem was in deed caused by a non-standard form of ismatrix.
Name-space conflicts in user added libraries is fun... ;)

Sign in to comment.

Categories

Find more on Matrices and Arrays 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!