The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: lookup cell array for string and take corresponding value
Replies: 1   Last Post: Dec 13, 2012 4:20 PM

Advanced Search

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

Posts: 55
Registered: 12/11/12
Re: lookup cell array for string and take corresponding value
Posted: Dec 13, 2012 4:20 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

W dniu 2012-12-13 22:06, Shashank Amburkar pisze:
> I've got a 2000x2 cell array that has strings in both columns. The
> strings in the first column go from A1 to A32 (but repeat so you may see
> A1, A2, A1, A1, A5....) and the strings in the 2nd column are either
> E,W,N,S and correspond to the one of the strings in the first column
> (and are always the same for a given first column string - A1 will
> always be E, A2 will always be W....). I want to build a 32X2 cell
> array that has A1 thru A32 on the first column with their corresponding
> 2nd column strings (E,W,N,S).

Use unique and extract indexes.

A = {'2','w';'3','e';'2','w';'1','n'}
B = A(I,:);


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.