I am learning MATLAB and was trying to code the following. Write a function called “buildrandomstrings” that will receive as input an integer n.Now If n is +ve: it will create and return a cell array with strings of random characters of increasing lengths, from 1 to n. Each string will be constituted by the previous random string plus an extra random character.
Now my code-
function buildrandomstrings = buildrandomstrings(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
buildrandomstrings= cell(1, posint);
inchar = char(inchar-1);
strin = '';
for i = 1:posint
strin = strcat(strin, char(inchar+i));
buildrandomstrings{i} = strin;
end
end
But I am getting the following error which makes no sense to me. Even though I have looked everywhere.
buildrandomstrings(4)
Not enough input arguments.
Error in buildrandomstrings (line 7)
buildrandomstrings= cell(1, posint);
When I do ctrl+click I get the following.
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