Fliplr and flipud functions no longer accepts vectors
조회 수: 11 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2011년 3월 22일
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
2018년 7월 31일
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?
채택된 답변
Matt Fig
2011년 3월 22일
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?
댓글 수: 0
추가 답변 (3개)
Matt Tearle
2011년 3월 22일
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
댓글 수: 0
John D'Errico
2011년 3월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!