Pluralization - MATLAB Cody - MATLAB Central

Problem 1832. Pluralization

  • Created by Tim

Define function plu(n) that returns '' (an empty string) if n=1, or 's' otherwise. This is handy for displaying messages from a program. For example,

   disp([num2str(n) ' point' plu(n) ' removed'])

produces

   0 points removed
   1 point removed
   2 points removed

etc., which is a little nicer than the typical alternative

   0 point(s) removed
   1 point(s) removed
   2 point(s) removed

and infinitely better than

   0 points removed
   1 points removed
   2 points removed

Solution Stats

63.23% Correct | 36.77% Incorrect
Last Solution submitted on May 05, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers84

Suggested Problems

More from this Author11

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page