Path: news.mathworks.com!not-for-mail
From: "Branko " <bogunovic@mbss.org>
Newsgroups: comp.soft-sys.matlab
Subject: reading alphanumeric data
Date: Thu, 5 Nov 2009 07:38:01 +0000 (UTC)
Organization: National Institute of Biology
Lines: 65
Message-ID: <hctvcp$ldp$1@fred.mathworks.com>
References: <hb6otr$oq4$1@fred.mathworks.com> <hb9c01$32e$1@fred.mathworks.com> <hbn2eo$p1$1@fred.mathworks.com> <hbp3cn$n2i$1@fred.mathworks.com> <hbs8m5$86$1@fred.mathworks.com> <hbsa1m$rbd$1@fred.mathworks.com> <hbsbcr$omg$1@fred.mathworks.com> <hc3k9d$6ha$1@fred.mathworks.com> <hc9kdi$a3m$1@fred.mathworks.com> <hcbg29$3td$1@fred.mathworks.com> <hcrk3f$l2p$1@fred.mathworks.com> <hcrlth$qc0$1@fred.mathworks.com> <hcrnnp$2jj$1@fred.mathworks.com> <hcrp4m$9ld$1@fred.mathworks.com> <hcs374$19l$1@fred.mathworks.com>
Reply-To: "Branko " <bogunovic@mbss.org>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257406681 21945 172.30.248.37 (5 Nov 2009 07:38:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 07:38:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 237386
Xref: news.mathworks.com comp.soft-sys.matlab:582635

"burcu " <burcu102@hotmail.com> wrote in message <hcs374$19l$1@fred.mathworks.com>...
> Thanks for this detailed explanation and your patience. I've checked every little item that you adviced me, help guides etc. but i'm still geting the same result. 
> 
> String_data=cat(1,String_data{:});
> ??? Error using ==> cat
> CAT arguments dimensions are not consistent.
> 
> if i try this as String_data=cat(2,String_data{:}); there is no error but the format is not that i need. 
> May i ask the version of matlab you're using? 
> If you dont have any other advice, maybe trying to reconstruct a new matrix from this String_data=cat(2,String_data{:}) output and trying to merge string and numeric data after that would be a solution. 
> 
> Burcu
> 
> > 
> > I see you are not getting there.  I will go through step by step otherwise will not get through this problem.
> > 
> > 1. Copy data bellow to word,notepad or whatever text editor you are using and name it data.txt:
> > 
> > '0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
> > '0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
> > '0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
> > 
> > 2. Use bellow code and run it:
> > 
> > fid = fopen('data.txt','rt');
> > data=textscan(fid,'%s','delimiter');
> > fclose(fid);
> >  
> > % Engine - use regexp!
> > data=cat(1,data{:});
> > String_data=regexp(data,'([A-Z a-z]+)','match'); % Remove all numeric
> > Numeric_data=regexp(data,'([0.00-9.99]+)','match'); % Remove all letters
> >  
> > Numeric_data=cat(1,Numeric_data{:});
> > String_data=cat(1,String_data{:});
> > DATA=[String_data(:,1:end-1) Numeric_data(:,1:end-1) String_data(:,end)]; 
> > 
> > And it should work!
> > 
> > I recommend you to read ML manual (help) about the function used in above example so that you can understand how problem is solved (and not just copy paste).
> > 
> > Branko 

Burcu,

Again and again you are repeating same mistake. Error is occuring due to data that you are pasting into file:
data={'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'};

and error message(same as you are showing):
??? Error using ==> cat
CAT arguments dimensions are not consistent.
String_data=cat(1,String_data{:});

BUT if you were pasting:
'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'
'0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00'

& run above code will work!

If you were doing as I wrote above it should work. It's working on ML 2007a & 2008a.

Branko