Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:45:18+00:00 2026-06-16T17:45:18+00:00

I am using a cell array to contain 1×2 vectors of grid locations in

  • 0

I am using a cell array to contain 1×2 vectors of grid locations in the form [row, col].
I would like to check if another grid location is included in this cell array.

Unfortunately, my current code results in an error, and I cannot quite understand why:

in_range = ismember( 1, ismember({[player.row, player.col]}, proximity(:,1)) );

where player.row and player.col are integers, and proximity‘s first column is the aforementioned cell array of grid locations

the error I am receiving is:

??? Error using ==> cell.ismember at 28
Input must be cell arrays of strings.

Unfortunately, I have not been able to find any information regarding using ismember() in this fashion, only with cell arrays as strings or with single integers in each cell rather than vectors.

I have considered converting using num2str() and str2num(), but since I must perform calculations between the conversions, and due to the number of iterations the code will be looped for (10,000 loops, 4 conversions per loop), this method seems prohibitive.

Any help here would be greatly appreciated, thank you

EDIT: Why does ismember() return this error? Does it treat all vectors in a cell array as string arrays?

EDIT: Would there be a better / more efficient method of determining if a 1 is in the returned vector than

ismember( 1, ismember(...))?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:45:20+00:00Added an answer on June 16, 2026 at 5:45 pm

    I’m short of time at the moment (being Chrissy eve and all), so this is going to have to be a very quick answer.

    As I understand it, the problem is to find if an x y coordinate lies in a sequence of many x y coordinates, and if so, the index of where it lies. If this is the case, and if you’re interested in efficiency, then it is wasteful to mess around with strings or cell arrays. You should be using numeric matrices/vectors for this.

    So, my suggestion: Convert the first row of your cell array to a numeric matrix. Then, compare your x y coordinates to the rows of this numerical matrix. Because you only want to know when both coordinates match a row of the numerical matrix, use the 'rows' option of ismember – it will return a true only on matching an entire row rather than matching a single element.

    Some example code that will hopefully help follows:

    %# Build an example cell array with coordinates in the first column, and random strings in the second column
    CellOfLoc = {[1 2], 'hello'; [3 4], 'world'; [5 6], '!'};
    
    %# Convert the first column of the cell array to a numerical matrix
    MatOfLoc = cell2mat(CellOfLoc(:, 1));
    
    %# Build an example x y coordinate location to test
    LocToTest = [5 6];
    
    %# Call ismember, being sure to use the rows option
    Index = ismember(MatOfLoc, LocToTest, 'rows');
    

    Note, if the indices in your cell array are in string form, then obviously you’ll also need a call to str2num in there somewhere before you call ismember.

    One other thing, I notice you’re a new member, so welcome to the site. If you think this response satisfactorily answered your question, then please mark the question answered by clicking the tick mark next to this response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I create a cell array using: clear all data = {rand(1,5),rand(1,4),rand(1,4),rand(1,6)}; a =
Using regexp with tokens on cell array of strings I've got cell array of
I have a Moose class that i would like to store using Apache::Session::File. However,
I am creating custom cell contain UILabel , UIImageView ,using constant tag for UILabel
I am trying to create a table using CGI.pm. The table would contain results
I created a cell array in Octave. Some columns contain floats, and some columns
I have a cell array like a={'potential'; 'impact'; 'of'; 'stranded'; 'assets'; 'and'; 'other'; 'necessary';
I retrieve a cell using dequeueReusableCellWithIdentifier and am logging the width of it. When
I'm building a table cell using two bound ember.js views on data. When I
In Excel I have attached a picture to a cell using the following Sub

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.