From: Jan Simon on
Dear Sscnekro!

> c = arrayfun(@(col) strcat(a{1,col}, ' = ', [blanks(1) num2str(b(1,col))] ), 1:size(b,2),'Unif', false)';

STRCAT deletes the trailing spaces of ' = ' and NUM2STR is a giantic wrapper for SPRINTF here. Therefore I'd prefer:
c = arrayfun(@(col) sprintf('%s = %d', a{col}, b(col))] ), ...
1:size(b,2),'Unif', false)';

Kind regards, Jan
From: sscnekro on
> c = arrayfun(@(col) sprintf('%s = %d', a{col}, b(col))] ), ...
1:size(b,2),'Unif', false)';

There were a bit too many brackets I think...
c = arrayfun(@(col) sprintf('%s = %d', a{col}, b(col)), 1:size(b,2),'Unif', false)';

> STRCAT deletes the trailing spaces of ' = ' and NUM2STR is a giantic wrapper for SPRINTF here. Therefore I'd prefer:

I'll try to remember. You know, a few days ago I was not able to move with cellfun / arrayfun and it's ONLY that I read some posts. It's good learning here (I am even pending with a homework from Walter :( ...
From: Walter Roberson on
sscnekro wrote:
>> a = {'one' 'two' 'three'};
>> b = [1 2 3];
>
> Hi there, is this what you want?
> c = arrayfun(@(col) strcat(a{1,col}, ' = ', [blanks(1)
> num2str(b(1,col))] ), 1:size(b,2),'Unif', false);
>
> PS Walter, us, Jan, dpb, Steve, Bruno, Jos & co.: have you noticed some
> progress in my programming skills???

Yes, definite improvement, and I for one appreciate you contributing
your time and skills to answering other people's questions. I know that
I often skip the easier questions under the assumption that someone else
will answer them; one tends to "burn out" answering the same questions
over and over again.
From: sscnekro on
> appreciate you contributing

Thanks. There is not much I can contribute but I try to balance between posts when I need help and posts to offer some. Of course I am a bit afraid that I will advise people wrongly, thus hoping that somebody advanced will eventually correct me.
From: us on
jrenfree <jrenfree(a)gmail.com> wrote in message <7d244640-b157-448e-bef5-b4e0b7fc78f0(a)11g2000prv.googlegroups.com>...
> Hi all,
>
> I'm running into trouble using sprintf to display data when I have a
> cell array of strings. For an example, let's say I have:
>
> a = {'one' 'two' 'three'};
> b = [1 2 3];
>
> I'd like my output to say:
>
> one = 1
> two = 2
> three = 3
>
> but when I try:
>
> sprintf('%s = %d\n', a, b)
>
> It gives me an error about using cell arrays in sprintf. Anything
> else I try, such as a{:}, [a{:}], char(a), etc... doesn't work.
>
> Any tips?
>
> Thanks!
>
> -J

this FEX submission might be helpful...

http://www.mathworks.com/matlabcentral/fileexchange/23840

us