Q:

What does the blanks function return when a 0 is passed to it? A negative number? Write a function myblanks that does exactly the same thing as the blanks function, using the programming method. Here are some examples of calling it:

0

 What does the blanks function return when a 0 is passed to it? A 

negative number? Write a function myblanks that does exactly the 

same thing as the blanks function, using the programming method. 

Here are some examples of calling it:

>> fprintf('Here is the result:%s!\n', myblanks(0))

Here is the result:!

>> fprintf('Here is the result:%s!\n', myblanks(7))

Here is the result: !

>> nob = blanks(0)

nob =

 Empty string: 1-by-0

>> nob = blanks(-4)

nob =

 Empty string: 1-by-0

>>

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

myblanks.m

function outa = myblanks(num)

% Mimics the blanks function

% Format of call: myblanks(n)

% Returns a string of n blanks

outa = '';

if num > 0

 for i = 1:num

 outa = [outa ' '];

 end

end

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now