How do you replace the entry of a matrix with a string?
Show older comments
I'm a little stuck
Accepted Answer
More Answers (2)
Jos (10584)
on 28 Nov 2013
I suggest to use a cell array and keep the original numerical matrix for finding the elements that have to change:
X1 = randi([0 6],10,10)
X2 = num2cell(X1)
X2(X1 == 1) = {'Tuesday'}
1 Comment
oshawcole
on 6 Dec 2017
can you write this code in one line?
Azzi Abdelmalek
on 28 Nov 2013
a=[0;1;2;3]
b=num2cell(a)
b{1}='Monday'
Categories
Find more on Logical 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!