how can I delete from a string a couple of lines I have indexed

16 次查看(过去 30 天)
Hi so I've got a string and I've got a variable that contains the position of different messages from the string. How could I delete the lines I got in the variable?

采纳的回答

Cris LaPierre
Cris LaPierre 2021-11-8
编辑:Cris LaPierre 2021-11-8
If it is a string array, and you want to remove a portion of a string in the array consider using eraseBetween:
If you have an array where each row contains a string, and you just want to remove entire rows, use indexing to set those rows equal to [].
myStr(rmvPositions) = [];

更多回答(1 个)

Kevin Holly
Kevin Holly 2021-11-8
Are you looking for something like this?
str = ["line 1";"line 2";"line 3";"line 4";"line 5"]
str = 5×1 string array
"line 1" "line 2" "line 3" "line 4" "line 5"
var = [2 3];
str(var)=[]
str = 3×1 string array
"line 1" "line 4" "line 5"

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by