How do I input a different character into a matrix full of characters?

1 view (last 30 days)
I have generated a matrix using the following code (width and height are user input):
field = ones(width,height) .* 'O';
field = char(field);
I need to put a letter different from 'O' at several points across only one row (say the top row).

Accepted Answer

the cyclist
the cyclist on 31 Jan 2016
width = 4;
height = 5;
field = ones(width,height) .* 'O';
field = char(field);
field(1, [2 3 5]) = 'K'

More Answers (0)

Categories

Find more on Matrices and Arrays 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!