|
On Jul 27, 10:16 pm, "CNN " <cnln2...@yahoo.co.uk> wrote:
> Rick Branch <rbranch6...@gmail.com> wrote in message <36681641-ae66-474d-8756-877c12fb1...@e35g2000vbl.googlegroups.com>...
> > On Jul 27, 11:15 am, "CNN " <cnln2...@yahoo.co.uk> wrote:
> > > Good day
> > > I'm trying to get the percentage sign printed in a string in my m-file. So I tried to test my options and I'm not getting the answer I expected. Could anyone tell me what I doing wrong here?
> > > str1 = {num2str(sum(a),'%%')}
> > > or
> > > str1 = sprintf('%%',sum(a))
>
> > > where a = 1:2:20
>
> > > I just need str1 to contain one value '100%'
>
> > > Thanks in advance.
>
> > sprintf('%d%%', sum(a))
>
> Thanks, both answers worked. But I don't understand the format '%d%%'. I know '%d' formats 'sum(a)' as an integer so do the remaining %% provide the percentage sign? If that is the case, why didn't it work for me? Do I really have to indicate that it is an integer first?
well...
YES... how could it possibly be otherwise(?)... a built-in, magic
thought-reader (albeit, CSSMers are still waiting for that particular
tbx by steve eddins)...
more wisdom may be collected by typing this into the command window
doc sprintf;
us
|