Comments on: split a delimited string in matlab http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/ tricks! Thu, 02 Feb 2012 20:46:58 +0000 hourly 1 http://wordpress.org/?v=3.1.1 By: Sana http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-24062 Sana Thu, 08 Dec 2011 13:48:35 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-24062 I tried what you said and the out come was: s='hi this is me' s = hi this is me >> l= strread(s, '%s', ',','\n'); ??? Unknown option ','. Error in ==> strread at 51 [varargout{1:nlhs}]=dataread('string',varargin{:}); I tried what you said and the out come was:

s=’hi this is me’

s =

hi this is me

>> l= strread(s, ‘%s’, ‘,’,'\n’);
??? Unknown option ‘,’.

Error in ==> strread at 51
[varargout{1:nlhs}]=dataread(‘string’,varargin{:});

]]>
By: Eric http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-17164 Eric Sat, 11 Jun 2011 22:41:20 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-17164 For those with old Matlab versions. You can split text with strread(), e.g. to split a long string at line breaks, do this: lines = strread(text, '%s', 'delimiter', '\n'); This will give you a cell array. regexp also works on cell as input, yielding a cell-of-cells as output. strread() doesn't and you'll have to loop manually. HTH, Eric For those with old Matlab versions.

You can split text with strread(), e.g. to split a long string at line breaks, do this:

lines = strread(text, ‘%s’, ‘delimiter’, ‘\n’);

This will give you a cell array.
regexp also works on cell as input, yielding a cell-of-cells as output. strread() doesn’t and you’ll have to loop manually.

HTH,

Eric

]]>
By: Ramon Fincken http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-11959 Ramon Fincken Thu, 27 May 2010 12:41:15 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-11959 Excellent, thanks. The answer is indeed a cell array: I have filenames like A__somethinghere.png To get the 'A' I use this in my loop: temp = dirList(x).name; temp2 = regexp (temp,'__','split'); imagegroup = temp2{1,1}; Excellent, thanks. The answer is indeed a cell array:

I have filenames like
A__somethinghere.png

To get the ‘A’ I use this in my loop:
temp = dirList(x).name;
temp2 = regexp (temp,’__’,'split’);
imagegroup = temp2{1,1};

]]>
By: yashu http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-11891 yashu Thu, 01 Apr 2010 18:22:14 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-11891 hii.. want to divide kanada word into single characters using matlab code .how should i write the code ??' plz send me the code ........ tanx alot .........:) hii.. want to divide kanada word into single characters using matlab code .how should i write the code ??’

plz send me the code ……..
tanx alot ………:)

]]>
By: John http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-11450 John Thu, 20 Aug 2009 18:42:04 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-11450 In matlab you have to use the regexp function with the 3rd, optional argument set to 'split'. It's silly, but that's how they chose to do it. Full syntax: TargetVar = regexp('(any string)','(delimiter)','split'); The output is a cell array (maybe two deep, I don't remember) with the entries you want. Type help regexp. In matlab you have to use the regexp function with the 3rd, optional argument set to ‘split’. It’s silly, but that’s how they chose to do it. Full syntax:

TargetVar = regexp(‘(any string)’,'(delimiter)’,'split’);

The output is a cell array (maybe two deep, I don’t remember) with the entries you want. Type help regexp.

]]>
By: Geert http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-11202 Geert Tue, 26 May 2009 13:28:53 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-11202 Hi there, Thanks for this! I was driving me crazy that there was no simple solution for this in Matlab. There are some functions around but none as efficient as yours. And, I could not find this in the Matlab reference (R2006b). The 'split' option is nowhere to be found. GNU Octave has the 'split' function that does just this and this was giving me headaches when porting my code to Matlab. Thanks again. Hi there,

Thanks for this! I was driving me crazy that there was no simple solution for this in Matlab. There are some functions around but none as efficient as yours. And, I could not find this in the Matlab reference (R2006b). The ‘split’ option is nowhere to be found.

GNU Octave has the ‘split’ function that does just this and this was giving me headaches when porting my code to Matlab.

Thanks again.

]]>
By: Peter http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-10988 Peter Thu, 26 Feb 2009 21:55:48 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-10988 Hey Lawrence, 1) I really like your photo-navigation! That's quite creative. 2) When you are giving help on a particular application such as Matlab, please list the version that you are using. In v6.5.2, I get "Invalid option for regexp: split." I found that my version of regexp only accepts two arguments anyway. Thanks. Hey Lawrence,

1) I really like your photo-navigation! That’s quite creative.

2) When you are giving help on a particular application such as Matlab, please list the version that you are using. In v6.5.2, I get “Invalid option for regexp: split.” I found that my version of regexp only accepts two arguments anyway.

Thanks.

]]>
By: srividhya http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/comment-page-1/#comment-10962 srividhya Mon, 23 Feb 2009 17:03:43 +0000 http://desk.stinkpot.org:8080/tricks/index.php/2008/11/split-a-delimited-string-in-matlab/#comment-10962 hi.. i have a string.. a='university' i want to split this into uni,ver,sity.. how can i do this in matlab.. please reply for me..am badly in need of this solution. thank u so much..... hi..
i have a string..
a=’university’
i want to split this into uni,ver,sity..
how can i do this in matlab..
please reply for me..am badly in need of this solution.
thank u so much…..

]]>