Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Extracting certain elements of a string (Matlab)

  1. Jan 31, 2008 #1

    I am writing a program in Matlab and I want to search a string within a cell to identify where certain characters start and end. However, once I identify the start and end points I want to extract all the characters within that range.

    So for example let's say that I have a 25 row by 1 column cell array called Carray. Let's also say that I'm only interested in the string that is within the 25th row cell. What I'm wanting to do is use something like the "findstr" or "strfind" functions in Matlab to give the the start and finish indices for a string like "bleh". Then I want to be able to take those four characters only from the entire string that is contained in the 25th row.

    if i==25
    bleh=strfind(able, 'CTDI')
    bleh1=strfind(able, 'DLP')
    % new able = extract the characters between the subindices bleh and bleh1 from cell able(25)

    Really all I need to know is if there is a way to specify subindices or something within the able array so that only certain characters in a particular cell are extracted?

    I'd really appreciate any advice in this matter and I hope that I have managed to explain it OK!

    Thank you
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted