From: Jessica on
Hi,
Does anyone know how to convert a series of numbers into a
single value with a colon inbetween the numbers. For
example,

a=5;b=75,c=8;

And I would like to produce:

5:75:8
From: Adam Chapman on
On May 5, 1:25 pm, "Jessica " <jyorzin...(a)ucdavis.edu> wrote:
> Hi,
> Does anyone know how to convert a series of numbers into a
> single value with a colon inbetween the numbers. For
> example,
>
> a=5;b=75,c=8;
>
> And I would like to produce:
>
> 5:75:8

Use the 'disp' command, it displays text. You need to convert your
numbers to a text format though, with the 'num2str command. Type 'doc
disp' in you comand line for help.

the code for displaying what you asked is:
disp([num2str(a) ':' num2str(b) ':' num2str(c)]);


Hope this helps,
Adam
From: Lorenzo Guerrasio on
It depends on what you need to do, but you may use a cell
format and the command num2cell.

"Jessica " <jyorzinski(a)ucdavis.edu> wrote in message <fvmub0
$rfg$1(a)fred.mathworks.com>...
> Hi,
> Does anyone know how to convert a series of numbers into
a
> single value with a colon inbetween the numbers. For
> example,
>
> a=5;b=75,c=8;
>
> And I would like to produce:
>
> 5:75:8

From: Jos on
"Jessica " <jyorzinski(a)ucdavis.edu> wrote in message
<fvmub0$rfg$1(a)fred.mathworks.com>...
> Hi,
> Does anyone know how to convert a series of numbers into a
> single value with a colon inbetween the numbers. For
> example,
>
> a=5;b=75,c=8;
>
> And I would like to produce:
>
> 5:75:8

What do you mean by "single value"? A string (=character
array) used for display purposes? If so,

sprintf('%d:%d:%d',a,b,c)

will do.

Also note that in matlab the command A:B:C means a list of
numbers running from A to C with steps B

hth
Jos
From: Roger Stafford on
"Jessica " <jyorzinski(a)ucdavis.edu> wrote in message <fvmub0$rfg
$1(a)fred.mathworks.com>...
> Hi,
> Does anyone know how to convert a series of numbers into a
> single value with a colon inbetween the numbers. For
> example,
>
> a=5;b=75,c=8;
>
> And I would like to produce:
>
> 5:75:8
---------
If I understand you correctly, you can only do that if your series is an
arithmetic progression - that is, if all the successive differences are equal
(within rounding error.) If x is a row vector with such a sequence (with at
least two elements,) then you can use

y = x(1):x(2)-x(1):x(end);

in place of x. However, note that rounding errors can cause very small
differences between y and x.

Is this what you are asking for? Your example is rather puzzling since it
consists of the single scalar 5. The next value after 5 would be 5+75=80
which is beyond 8 and therefore not in the series.

Roger Stafford