Write a function buildstr that will receive a character and a positive integer n. It will create and return a cell array with strings of increasing lengths, from 1 to the integer n
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:8| Question number:8.8
All Answers
total answers (1)
buildstr.m
function outcell = buildstr(inchar, posint)
% Creates a cell array with strings of increasing
% lengths, from 1:n, starting with inchar
% Format of call: buildstr(input char, n)
% Returns cell array with n strings
outcell =cell(1,posint);
inchar = char(inchar-1);
strin = '';
for i = 1:posint
strin = strcat(strin, char(inchar+i));
outcell{i} = strin;
end
end
need an explanation for this answer? contact us directly to get an explanation for this answer