How to replace values in a matrix?
古いコメントを表示
Hello,
I am fairly new to MATLAB and I have a question. How do you replace a value in a matrix? So if I have a matrix A, where A=3,2,5,-6. How can I find, and replace all of the negative numbers with 0? So I want to end up with a matrix of 3,2,5,0.
Thank you!
Molly
採用された回答
その他の回答 (1 件)
Molly Baltins
2015 年 9 月 21 日
0 投票
5 件のコメント
Star Strider
2015 年 9 月 21 日
My pleasure!
Molly Baltins
2015 年 9 月 22 日
Star Strider
2015 年 9 月 22 日
My pleasure!
I’m not quite certain what you’re asking, so I’ll take a guess at an answer:
str = 'Molly';
result1 = str(1:5)
result2 = str([3 1 5 2 4])
result1 =
Molly
result2 =
lMyol
I used the colon (:) operator to create the subscript vector in ‘result1’. It is the same as typing [1 2 3 4 5].
Molly Baltins
2015 年 9 月 22 日
Star Strider
2015 年 9 月 22 日
Again, my pleasure!
カテゴリ
ヘルプ センター および File Exchange で Text Analytics Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!