How to write a function to test for positive or negative numbers
Afficher commentaires plus anciens
Hi! I need to write a function that takes in numerical data as input argument and prints a message to the command window stating if the number is positive, negative or zero.
Réponse acceptée
Plus de réponses (3)
Rik
le 4 Oct 2017
0 votes
Have a look at the function sign, or solve this with if, elseif and else.
For printing text to the terminal, you can use disp or fprintf.
If you have trouble using one of these functions, you can open the documentation with doc FunctionName
Yenchia Feng
le 30 Déc 2020
Try
doc sign
Hope this helps!
suvam
le 22 Août 2023
0 votes
check whether an alphabet is vowel or consonant
1 commentaire
This is not an answer to the question about positive an negative numbers. Why would you hide a question in an old unrelated thread unless you want nobody to answer it?
If you have a question, ask a question. Provide enough specific information about the task so that others know what your requirements are. This is relevant, because the question you've asked requests a misrepresentation of what vowels and consonants are. It really only warrants the naive answer. If you want something other than a naive, generally wrong answer, the problem isn't simple anymore, and you need to be more specific about what you're calling a "vowel".
See also PLL's comment on that answer.
... also, nobody said we're talking about english.
Catégories
En savoir plus sur Entering Commands dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!