This replaces the hyphen with a space.
You can use the loop if you want. You simply have to tweak it:
n = length(str);
for k = 1:n
if strfind(str(k),'-')
str(k) = ' ';
end
strOut = str;
end
A simpler implementation eliminates the loop entirely:
The loop is the problem. Just use strfind:
k = strfind(str,'-')
str(k) = ' ';
There are other functions that will do this more effieicntly (that I will let you search out).
Best Answer