Hello, I am trying to create a function that will cut a section out of a string and join the two remaining parts togather.
I am getting some weird results towards the end
here is my code
pat = 'MATLAB';cliplength = length(pat);stringinput = 'D:\Documents and Settings\212068586\My Documents\MATLAB\help'endpoint = regexp(stringinput, pat);newstringstart = [];newstringtail = [];for w = 1:length(stringinput) if w < endpoint newstringstart(w) = stringinput(w); endend if (((endpoint + cliplength) < w) && (w > endpoint)) for h = (endpoint + cliplength):length(stringinput) newstringtail(h) = stringinput(w); end %newstring(w) = stringinput(w - (endpoint + cliplength));
enddisp(char(strcat(newstringstart, newstringtail)))
Any ideas why it isn't working?
Thanks
Bill
Best Answer