MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodaySearch Solutions

1 – 33 of 33 previous next

121Size

0 Comments

50Size

0 Comments

52Size

0 Comments

145Size

0 Comments

57Size

0 Comments

101Size

0 Comments

83Size

0 Comments

52Size

0 Comments

73Size

0 Comments

99Size

0 Comments

146Size

0 Comments

50Size

0 Comments

126Size

0 Comments

81Size

0 Comments

90Size

0 Comments

110Size

0 Comments

92Size

0 Comments

56Size

0 Comments

56Size

0 Comments

60Size

0 Comments

138Size

0 Comments

52Size

6 Comments

1 player likes this solution

6 Comments

Show
3 older comments

Peng Liu
on 6 Dec 2015

This solution doesn't work on R2015a or R2015b. It seems that the behavior of circshift is changed. For example, circshift(sparse(logical([1 2 3])),[0 1]) on R2015b returns all zeros.

Jan Orwat
on 6 Dec 2015

Hi Peng, it seems that last major changes to circshift were introduced in 2014a (dim selection added). I'm not able to check this version, 2015a also returns falses. Anyway, (not) nice bug :).

Peng Liu
on 7 Dec 2015

Hi Jan, I don't have 2014a either. But I was able to check with 2013a available here: http://anycodes.cn (On the left hand side, you can select to run MATLAB). While circshift(sparse(logical([1 2 3])),[0 1]) and circshift(sparse(+logical([1 2 3])),[0 1]) produce different output on 2015a and 2015b, they give the same result (up to a class difference) on 2013a.

Jan Orwat
on 8 Dec 2015

It's definitely a bug. It seems the newest version of circshift doesn't handle sparse logical matrices properly. It somehow changes trues to falses, but treat them like nonzeros. This leads to some funny logical properties because of the way the algorithms for sparse matrices work. Check following code: A = circshift(sparse([false false true false true]),[0 1]); A, nonzeros(A); full(A), A|1, A&1, ~A, xor(A,1), xor(A,0), and(A,A), or(A,A), A==~~A, isequal(A,~~A), isequal(A|0,A), %(etc.);
B = sparse([false false true false true]); B, B = B([end 1:end-1]), ...

Jan Orwat
on 8 Dec 2015

This is my favourite:
C = circshift(sparse(true),1);

Peng Liu
on 8 Dec 2015

Haha, this is definitely a funny example to elaborate on the improper behavior of circshift/sparse when dealing with sparse logical matrix. I agree with you this is a bug, but still not very sure the bug is due to circshift or sparse. Maybe somebody can report this bug to MATHWORKS...

55Size

0 Comments

93Size

0 Comments

55Size

0 Comments

57Size

0 Comments

54Size

0 Comments

55Size

0 Comments

55Size

0 Comments

57Size

0 Comments

58Size

0 Comments

58Size

0 Comments

61Size

0 Comments

1 – 33 of 33 previous next