strings become numbers and get in to the matrix
2 views (last 30 days)
Show older comments
i have a matrice
[1 0 -1 -1 2 -1 1
1 0 -1 -1 2 -1 1
1 -1 0 -1 2 -1 1
1 0 -1 -1 2 -1 1];
and where the number is positive i need to replace ' i ' upon the ASCII is 105 , ( ' i ' its like increase )
where the number is negative i need to replace ' d ' upon the ASCII is 100 ( ' d ' its like decrease )
and where the number is 0 i need to replace ' s ' upon the ASCII is 115 ( ' s ' its like same )
------------------------------------------
for example : if i have vector [ -1 , 0 , 1]
the new vector will be : [100 , 115 , 105 ]
0 Comments
Answers (1)
Star Strider
on 22 Dec 2019
Use logical indexing:
v = [ -1 , 0 , 1];
pos = v > 0
neg = v < 0
zro = v == 0
and then do the replacements.
0 Comments
See Also
Categories
Find more on String in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!