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 7092315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:17:53+00:00 2026-05-28T08:17:53+00:00

I am doing string processing in Matlab and I usually use cell arrays to

  • 0

I am doing string processing in Matlab and I usually use cell arrays to store individual words in the text

Example:

a = {'this', 'is', 'an', 'array', 'of', 'strings'}

For searching for the word ‘of’ in this array I loop through the array and check each individual element against my word. This method does not scale since if I get a large dataset my array a will grow large and looping through elements is not wise. I am wondering if there is any more smart way, perhaps a better native data structure in Matlab, that can help me run this faster?

  • 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-05-28T08:17:54+00:00Added an answer on May 28, 2026 at 8:17 am

    A map container is one option. I don’t know what specific sort of string processing you intend to do, but here’s an example for how you can store each string as a key which is associated with a vector of index positions of that word in a cell array:

    a = {'this', 'is', 'an', 'array', 'of', 'strings', 'this', 'is'};
    
    strMap = containers.Map();  %# Create container
    for index = 1:numel(a)      %# Loop over words to add
        word = a{index};
        if strMap.isKey(word)
            strMap(word) = [strMap(word) index];  %# Add to an existing key
        else
            strMap(word) = index;  %# Make a new key
        end
    end
    

    You could then get the index positions of a word:

    >> indices = strMap('this')
    
    indices =
    
         1     7    %# Cells 1 and 7 contain 'this'
    

    Or check if a word exists in the cell array (i.e. if it is a key):

    >> strMap.isKey('and')
    
    ans =
    
         0    %# 'and' is not present in the cell array
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing some text processing, part of it is splitting words into single
I am currently doing a bunch of processing on a string using regular expressions
I'm trying to write a string processing function in F#, which looks like this:
For doing string concatenation, I've been doing basic strcpy , strncpy of char* buffers.
Python is doing string multiplication where I would expect it to do numeric multiplication,
Is there any better alternative for doing string formatting in VC6, with syntax checking
When doing a string comparison in C#, what is the difference between doing a
I'm doing simple string input parsing and I am in need of a string
What is the best way of doing case-insensitive string comparison in C++ without transforming
I've used strpbrk() occasionally while doing low-level string work in C, but I've never

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.