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!