"Oleg Komarov" <oleg.komarovRemove.this@hotmail.it> wrote in message <i5dv67$ie9$1@fred.mathworks.com>...
> "RAB John" <dkkddkkd@walla.com> wrote in message <i5dloc$ks7$1@fred.mathworks.com>...
> > Hello all,
> >
> > I wish to use text() and num2str() combination in order to text a graph in multiple point with out the use of a LOOP!
> > The only problem is num2str() producing one string instead of a strings vector.
> >
> > The code I tried is:
> >
> > text(1:2:5, abs(Y((1:2:5) + 1)), num2str(abs(Y((1:2:5) + 1))), '%1.3d'));
> >
> > where Y is a line vector.
> >
> > a simillar looped version would be:
> >
> > for i = 1:2:5
> > text(i, abs(Y(i + 1)), num2str(abs(Y(i + 1)), '%1.3d'));
> > end
> >
> > Any suggestion?
> > DK
>
> Try this one:
> text(1:3, 1:3, num2str(1:3, '%d').');
> set(gca,'Xlim',[0 3]);
> set(gca,'Ylim',[0 3]);
>
> Note the .' to obtain a column vector after num2str. I also would use
> sprintf('%d',1:3).'
>
> Oleg
Thx for the quick response!
Though it works fine the way you put it, it doesn't goes well when I add a function to the basic 1:3 vector.
I tried the following:
text(1:2:5, abs(Y((1:2:5) + 1)), num2str(Y(1:2:5), '%d').');
and
text(1:2:5, abs(Y((1:2:5) + 1)), num2str(abs(Y(1:2:5)), '%d').');
but both didn't work.
Any comments/suggestions?
RAB
