match a word/letter and add to the string cell - without a for loop
Ältere Kommentare anzeigen
Hi, I would like to check for a letter in a cell string and if it matches the letter I would like to add a word or a sentence to the string eg:
Initial cell:
P etc etc etc
A etc etc etc
P etc etc etc
A etc etc etc
Final Cell
aaa P etc etc etc
A etc etc etc
aaa P etc etc ect
A etc ect ect
My appologies I know this is a horible example.
However, I would like to accomplish this without using a for loop. I've tried to use cellfun but I couldnt figure out how to do it. Thank you
4 Kommentare
Azzi Abdelmalek
am 22 Aug. 2013
What is the size of your initial cell? are you looking for matching letter in the first column or in all the cell array?
Image Analyst
am 22 Aug. 2013
Bearbeitet: Image Analyst
am 22 Aug. 2013
What is in the cell? A 2D character array (in which case you'd have to pad it with blanks)? Or a 4 row by 1 column cell array of strings? (i.e. your single cell contains a cell array) Or do you have a 4 by 4 cell array in the cell, which then gets changed to a 4 by 5 cell array in a single cell? Or do you actually mean "cell array" instead of "cell"? So that you have a 4 by 1 cell array? Please read the FAQ on cells: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F so you can explain your situation/needs properly and precisely. As it is, it's ambiguous.
Sven
am 22 Aug. 2013
Yup, Vincent, I'll bet that if you can change your question so that you use actual code for your initialCell and finalCell, you'll have an answer returned within 10 minutes.
At the moment however your question is ambiguous because (for example) it's impossible to make a single cell look like the text you've provided for your finalCell, and it's not clear what your initialCell contents actually is.
Vincent I
am 26 Aug. 2013
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!