I want to remove hyphens (-
), slashes (/
) and white space () from a string
name(i)
so that I can use it as a structure field name.
This is the ugly way I am currently doing it using the function strrep
:
cell2mat(strrep(strrep(strrep(name(i), '-',''),'/',''),' ', ''))
I have also tried other variations, such as:
strrep(name(i),{'-','/'},{'',''});
strrep(name(i),['-','/'],['','']);
What is a more efficient way of doing this?