why ascii instead of letter?
3 ビュー (過去 30 日間)
古いコメントを表示
hi,
I want place 'a' instead of 1 as in :
x=[1 2 3 1]; >> for i=1:4 if x(i)==1 x(i)='a' end end
but the result: 97 2 3 97
why ascii is appearing?
0 件のコメント
回答 (2 件)
Walter Roberson
2011 年 9 月 19 日
You have initialized a numeric array rather than a character array. Numeric arrays cannot hold characters as characters. Only cell arrays can mix numerics with characters.
0 件のコメント
Fangjun Jiang
2011 年 9 月 19 日
Original x is a double array, but in your for-loop, you assign a char value to its element. So it takes the ASCII value of letter 'a'. see
double('a')
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!