Using if and then statements
4 次查看(过去 30 天)
显示 更早的评论
Write a MATLAB program to compute both roots of the quadratic equation as you input the values of a, b, and c.   Requirements:
a) Use “input” to ask the user to put in the values of a, b and c
b) Use “if” structure to avoid division by zero and complex roots
c) Print out the roots for the following situations:
(1). a=2, b=10, c=12
(2). a=0, b=10, c=4
(3). a=4, b=10, c=100
1 个评论
Stephen23
2015-9-17
Do you actually have a question, or do you just want us to do your homework for you?
回答(1 个)
Rick Rosson
2015-9-17
编辑:Rick Rosson
2015-9-17
function r = findQuadraticRoots(a,b,c)
if something is true
do some stuff;
else
do some other stuff;
end
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!