MATLAB: How to delete a value and the value next to it

deleteelementsstrrep

I want to delete 'S' elements and the number next to them in this char format
f = 'S 0 92 -707 1349 92 -708 1348 92 -708 1348 92 -709 1347 92 -709 1347 93 -710 1347 93 -711 1347 93 -711 1346 S -712 1346 94 -712 1346 94 -713 1345 95 -714 1345 95 -714 1344 95 -715 1344 96 -715 1344 96 -715 1343 S -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1344 96 -715 1344 96 -715 S 95 -715 1344 95 -714 1345 95 -714 1345'
To delete the 'S' I have used this code:
angles = sscanf(strrep(f,'S',''),'%d');
But I don't know to delete the element next to 'S' elements.

Best Answer

Try regexprep()
f = 'S 0 92 -707 1349 92 -708 1348 92 -708 1348 92 -709 1347 92 -709 1347 93 -710 1347 93 -711 1347 93 -711 1346 S -712 1346 94 -712 1346 94 -713 1345 95 -714 1345 95 -714 1344 95 -715 1344 96 -715 1344 96 -715 1343 S -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1343 96 -716 1344 96 -715 1344 96 -715 S 95 -715 1344 95 -714 1345 95 -714 1345';
angles = sscanf(regexprep(f, 'S\s(-)*[0-9]*', ''), '%d');