Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to separate the sentence

Subject: how to separate the sentence

From: wahyoe Unggul

Date: 30 Mar, 2011 13:43:06

Message: 1 of 6

hi all
how to separate the sentence
a = 'mat';
b = 'balt';
c =vertcat(strcat(a,b));
M=[2 4; 3 4];
disp(c)
disp(M)
 
result
matbalt
     2 4
     3 4

how can I make the result as below
mat balt
    2 4
    3 4

Subject: how to separate the sentence

From: ImageAnalyst

Date: 30 Mar, 2011 14:50:23

Message: 2 of 6

How about this?
c =vertcat(strcat(a,[' ' b]));

Not sure what you were really after. And not sure what role M was
playing in your code.

By the way, if you really have a sentence, you can use John's
"allwords" function to separate out each word. Also works great for
picking out the different folders and sub folders in a pathname.
http://www.mathworks.com/matlabcentral/fileexchange/27184-allwords

For example:

mySentence = 'this is a sentence';
ca = allwords(mySentence)

Results in command window:
ca =
    'this' 'is' 'a' 'sentence'


myFolder = 'C:\Program Files\MATLAB\work';
ca = allwords(myFolder, '\')

Results in command window:
ca =
    'C:' 'Program Files' 'MATLAB' 'work'

Subject: how to separate the sentence

From: wahyoe Unggul

Date: 30 Mar, 2011 15:24:04

Message: 3 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <ba98c7e2-a319-45b3-8668-4f16e60b868f@r14g2000vbm.googlegroups.com>...
> How about this?
> c =vertcat(strcat(a,[' ' b]));
>
> Not sure what you were really after. And not sure what role M was
> playing in your code.
>
> By the way, if you really have a sentence, you can use John's
> "allwords" function to separate out each word. Also works great for
> picking out the different folders and sub folders in a pathname.
> http://www.mathworks.com/matlabcentral/fileexchange/27184-allwords
>
> For example:
>
> mySentence = 'this is a sentence';
> ca = allwords(mySentence)
>
> Results in command window:
> ca =
> 'this' 'is' 'a' 'sentence'
>
>
> myFolder = 'C:\Program Files\MATLAB\work';
> ca = allwords(myFolder, '\')
>
> Results in command window:
> ca =
> 'C:' 'Program Files' 'MATLAB' 'work'


hi imagei,
I want to combine in a single matrix if that is possible, or whether there are tricks to display on the first line to the words, and the second row is a number, so when run will look like this
mat balt
   2 4
   3 4

Subject: how to separate the sentence

From: ImageAnalyst

Date: 30 Mar, 2011 15:29:22

Message: 4 of 6

You can use a cell array or a structure to combine different data
types in a single variable.

Subject: how to separate the sentence

From: wahyoe Unggul

Date: 30 Mar, 2011 15:45:05

Message: 5 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <dfe6946f-8a83-4986-afa3-16eb304aa441@32g2000vbe.googlegroups.com>...
> You can use a cell array or a structure to combine different data
> types in a single variable.

sorry, I do not understand, can you give an example, thanks

Subject: how to separate the sentence

From: Nasser M. Abbasi

Date: 30 Mar, 2011 16:41:34

Message: 6 of 6

On 3/30/2011 8:45 AM, wahyoe Unggul wrote:
> ImageAnalyst<imageanalyst@mailinator.com> wrote in message<dfe6946f-8a83-4986-afa3-16eb304aa441@32g2000vbe.googlegroups.com>...
>> You can use a cell array or a structure to combine different data
>> types in a single variable.


>
> sorry, I do not understand, can you give an example, thanks



EDU>> A{1}='hi, i am a string'
EDU>> A{2}=pi
EDU>> A{3}='that was easy'

A =
     'hi, i am a string' [3.1416] 'that was easy'



--Nasser

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us