Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!news-out.readnews.com!transit3.readnews.com!postnews.google.com!x35g2000hsb.googlegroups.com!not-for-mail
From: n o s p a m p l e a s e <nospam.please@alum.com>
Newsgroups: comp.soft-sys.matlab
Subject: Printing a cell array
Date: Thu, 8 May 2008 23:16:03 -0700 (PDT)
Organization: http://groups.google.com
Lines: 22
Message-ID: <b44e861c-f621-4d52-a70b-b433f7420339@x35g2000hsb.googlegroups.com>
NNTP-Posting-Host: 138.227.189.8
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1210313763 19212 127.0.0.1 (9 May 2008 06:16:03 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 9 May 2008 06:16:03 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: x35g2000hsb.googlegroups.com; posting-host=138.227.189.8; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
Xref: news.mathworks.com comp.soft-sys.matlab:467543


I have a cell array as follows:

Names = {'Jon' ; 'Hur' ; 'Osl' ; 'Got'};

I want to print them such one element goes in a line as follows:

1    Jon
2    Hur
3    Osl
4    Got

I wrote the following code:
nb = 4;
fid = fopen('myoutput.txt','w');
fprintf(fid, '\n %d     %s', [1:nb], Names{:});
fclose(fid);

but it is not working out properly.

Any suggestions.

NSP