how to use for loop for below.
古いコメントを表示
Task: Write a function named areaCircle to calculate the area of a circle. The function should take one input that is the radius of the circle. The function should work if the input is a scalar, vector, or matrix. The function should return, one ouput, the same size as the input, that contains the area of a circle for each correspoding element. If the input contains negative numbers, the function should return the value -1 at those locations to indicate the error.
These are code to call funtion. r1 = 2; area1 = areaCircle(r1) r2 = [2 5; 0.5 1]; area2 = areaCircle(r2) r3 = [1 1.5 3 -4]; area3 = areaCircle(r3)
2 件のコメント
James Tursa
2018 年 8 月 3 日
What have you done so far? What specific problems are you having with your code?
Rahul Kumbhar
2018 年 8 月 3 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!