How can I replace numbers in a vector by text ?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everybody!
I have a column in a csv file with 0 and 1 and I want to replace all the 0 values by FALSE and all the 1 values by TRUE. Anybody knows how can I do that? Thanks in advance!
I have been trying to do this but it doesn't work.
s(s==0)='FALSE'
0 件のコメント
回答 (1 件)
dpb
2014 年 6 月 1 日
s(s==0)='text';
won't work because you're trying to change datatypes piecewise in an array.
SOTOO,
>> s=rand(10,1)>0.5;
>> v={'t';'f'};t=v(s+1)
t =
't'
'f'
't'
't'
'f'
'f'
'f'
't'
'f'
't'
>>
8 件のコメント
Star Strider
2014 年 6 月 2 日
Oh. OK. Thought I’d been behind the door again.
Know about ‘table’ but haven’t used it much yet.
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!