Write a function rid_multiple_blanks that will receive a string as an input argument. The string contains a sentence that has multiple blank spaces in between some of the words
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:22.7
All Answers
total answers (1)
rid_multiple_blanks.m
function newstr = rid_multiple_blanks(str)
% Deletes multiple blanks from a string
% Format of call: rid_multiple_blanks(input string)
% Returns a string with multiple blanks replaced
% by a single blank space
while length(strfind(str,' ')) > 0
str = strrep(str,' ', ' ');
end
newstr = str;
end
need an explanation for this answer? contact us directly to get an explanation for this answer