Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Circshift applied to columns by different amounts
Replies: 5   Last Post: Mar 16, 2012 11:53 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Parag Chandakkar

Posts: 92
Registered: 8/30/09
Re: Circshift applied to columns by different amounts
Posted: Mar 16, 2012 8:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I think this solves the query, not the most efficient, but works...

a1=[1 2 3 4; 5 5 6 7; 1 3 4 NaN; 15 2 NaN NaN; 9 NaN NaN NaN];
>> a1

a1 =

1 2 3 4
5 5 6 7
1 3 4 NaN
15 2 NaN NaN
9 NaN NaN NaN

>> a2=isnan(a1);
for i=1:size(a1,2)
a3=a2(:,i);
a1new(:,i)=circshift(a1(:,i),length(a3(a3==1)));
end
a1new

a1new =

1 NaN NaN NaN
5 2 NaN NaN
1 5 3 NaN
15 3 6 4
9 2 4 7



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.