How to create a 1x12 matrix of only .

6 views (last 30 days)
M28
M28 on 11 Oct 2018
Answered: M28 on 12 Oct 2018
Hello I'm new to matlab and I need to creat a matrix of points . in matlab then combine it with string array.
  2 Comments
OCDER
OCDER on 11 Oct 2018
Can you show us what you want as the output? Example:
[Replace below with what you want as the output]
... + "this is a string" = "...this is a string" ??
M28
M28 on 12 Oct 2018
I got something like this:
a = [1;2;3];
b = [3;2;1];
aa = num2str(a);
bb = num2str(b);
and I want to add a '.' between each two values and get one single array at the end so it would look like this:
'1.3'
'2.2'
'3.1'

Sign in to comment.

Accepted Answer

M28
M28 on 12 Oct 2018
I solved it, thnx guys

More Answers (2)

Guillaume
Guillaume on 12 Oct 2018
a = [1;2;3];
b = [3;2;1];
Two easy options:
compose('%d.%d', a, b) %or compose("%d.%d", a, b) to get a string array instead of a cell array of char arrays
or
string(a) + "." + string(b)

madhan ravi
madhan ravi on 11 Oct 2018
Edited: madhan ravi on 12 Oct 2018
a = [1;2;3];
b = [3;2;1];
idx = [a b]
sprintf('%.f.%.f \n',idx')
EDITED
  3 Comments
M28
M28 on 12 Oct 2018
Hey, unfortunately it's not like that. It's like this: I want to get cc ofcurse without doing c !
a = [1;2;3];
b = [3;2;1];
aa = num2str(a);
bb = num2str(b);
c = [1.3;2.2;3.1];
cc = num2str(c);

Sign in to comment.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!