Using strrep for matrix

조회 수: 9 (최근 30일)
xRobot
xRobot 2019년 11월 19일
댓글: xRobot 2019년 11월 20일
Hello, I have some code that creates a scrambled character block of type char for instance
aaho
aoaa
daa
If i create a variable guess = 'hood'
how could i remove the word hood from the block and then display the block again with the removed 'hood'.
I have tried converting the block to a string array using "string()" then using "strrep() " to remove the the sequence and then convert it back to char but it did not work.
Any suggestions are greatly appeciated. Thanks in advance!

답변 (1개)

Guillaume
Guillaume 2019년 11월 19일
Keeping your 2d character array as is:
yourarray(ismember(yourarray, 'hood', 'rows'), :) = [];
or
yourarray(all(yourarray == 'hood', 2), :) = [];
  댓글 수: 1
xRobot
xRobot 2019년 11월 20일
Instead of using ‘hood’ could I put a variable in there? Say guess = hood. Could I put guess in your code and it would work the same?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulation and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by