Reputation: 215
I want a column vector that contains only the character A, that is,
A
A
A
A
like this. So i have tried
'A'*ones(4,1)
But in place of A, it takes on value 65. How can i get A ?
Upvotes: 2
Views: 41
Reputation: 38032
Multiplication of char
s with double
s gives double
s; the char
is cast to double
, using the corresponding ASCII value.
Just cast back to char
:
char('A'*ones(4,1))
but probably Luis' answer is faster ;)
Upvotes: 3
Reputation: 112749
You can do it this way:
repmat('A',4,1)
Or use your approach but include char
to convert back to string after the multiplication:
char('A'*ones(4,1))
Upvotes: 4