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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Muhammad
on 18 Sep 2013

Hey

I am getting problem to apply delimiter at particular column. My text file consists of delimited data but I want to use delimited tool only on particular column.

- for e.g. 03:30:45 in 1st column and Cellid:dBm in 2nd column. I want to apply delimiter : only at column 2.

Is there any way? Your respected opinions are appreciated.

Answer by Azzi Abdelmalek
on 18 Sep 2013

Edited by Azzi Abdelmalek
on 18 Sep 2013

Read all your data with delimiter then recreate the first column.

If

A{1}={'03';'03';'03'} A{2}={'30';'30';'30'} A{3}={'45';'46';'47'}

Then

first_column=cellfun(@(x,y,z) [x,':',y,':',z],A{1},A{2},A{3},'un',0)

Show 3 older comments

Azzi Abdelmalek
on 18 Sep 2013

If you have a cell array like:

s={'16 56 12 53172 -89';'17 56 12 53172 -90';'18 56 12 53172 -91'} a=regexp(s,'\s+','split') time1=cellfun(@(x) [x{1} ':' x{2} ':' x{3}],a,'un',0)

Muhammad
on 19 Sep 2013

Thanks for your reply.

Please find the attached file. I am using Matlab R2012b. I am importing my file and applying delimiter on the attached imported file. How could I apply delimiter on particular column using column delimiters option.

## 4 Comments

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/87531#comment_169622

It is not clear what you are talking about. There are some colons inside "03:30:45" already. How do you create the text file? Why not printing the colon directly?

## Muhammad (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/87531#comment_169649

I mean to say i have 2 columns one for time and the NID with dBm. i.e;

Time; NID01: dBm;

16:56:12; 53172; -89;

Now I am importing the text file and applying delimiter. I want to use : delimiter only in 2nd column 1st row. In general when I am using delimiter it is applying in all rows and columns in text file. Like if I am using two delimiters : and ; the result is

Time NID01 dBm

16 56 12 53172 -89

Means it is splitting the time also.

But I am looking for time(16:56:12) in the time column, NID(53172) in NID01 column and value (-89) under dBm column. Is there is any way to use delimiter only in particular row or column(like in our case in 2nd column 1st row). I am using delimiter tool.

Thanks

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/87531#comment_169686

What does "when I am using delimiter" exactly mean? Please post the code you are talking of. How can a delimiter "applied" during the import?

The example looks strange:

When these are

twocolumns, why do the 2nd line looks like 3 values?Posting the code you use, a clear small example for the input and a definition of the output in valid Matlab syntax would stop the discussion and allow for a fast solution of your problem.

## Muhammad (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/87531#comment_169828

Please find the attached file. I am using Matlab R2012b. I am importing my file and applying delimiter on the attached imported file. How could I apply delimiter on particular column using column delimiters option.