Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Matlab function named pluralize that takes 2 arguments: a noun and a umb

ID: 3827745 • Letter: W

Question

Write a Matlab function named pluralize that takes 2 arguments: a noun and a umber. Then, it returns the number and the pluralized form, like "5 cats" or "1 dog". Pay attention to the 's' you need to include for the plural form. Do not take into consideration countability/uncountability. Just assume if it is plural, you need include an 's'. Finally, if the number is less than or equal to zero, your program should return 'Invalid Number'.

Example: 1) pluralize ('Cat, 5')-> 5 Cats

2) pluralize ('Sugar,1')->1 Sugar

Explanation / Answer

here is matlab function

function s = pluralize(s, n)
if n <= 0
s = "Invalid Number";
return;
elseif n == 1
s = [num2str(n), ' ', s];
return;
else
s = [num2str(n), ' ', s, 's'];
end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote