Extracting values from a string - Matlab
3 次查看(过去 30 天)
显示 更早的评论
I am trying to take the values from the string "ind" following this logic:
ind = "i 1 1";
comp4 = strcmp(ind(1),"i")
if(comp4)
row = str2double(ind(3))
col = str2double(ind(5))
end
And for example the cond4 condition isn't validated, hence that's why I am asking why can't I take the values visualized of row and col.Thank you
0 个评论
采纳的回答
Fangjun Jiang
2023-3-10
You got string array (" ") and char array( ' ') mixed. See which data format fits you better.
ind = "i 1 1"
ind(1)
ind2=char(ind)
ind2(1)
3 个评论
Fangjun Jiang
2023-3-10
Or split() it first
ind = "i 1 1";
split(ind," ")
Steven Lord
2023-3-10
Or use extractBetween.
ind = "i 1 1";
row = extractBetween(ind, 3, 3)
rowDouble = double(row)
col = extractBetween(ind, 5, 5)
colDouble = double(col)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!