How to get the answer?

Create a function to calculate the area of three circles with different radius in your choice. use for loop to call the function and display the results as a column vector.

5 件のコメント

Adam
Adam 2018 年 3 月 28 日
Putting some effort in is usually the first thing needed to get the answer!
Abo Mohammed
Abo Mohammed 2018 年 3 月 28 日
I tried for over two days but i didn't get it :(
Birdman
Birdman 2018 年 3 月 28 日
Share what you have done so far.
Abo Mohammed
Abo Mohammed 2018 年 3 月 28 日
編集済み: Walter Roberson 2018 年 3 月 28 日
I created below function but still cannot understand how to disply the results as a column vector.
function Ca=Circle_area(r)
Ca=pi*r^2;
end

サインインしてコメントする。

回答 (1 件)

ES
ES 2018 年 3 月 28 日

0 投票

I have just reused your function.
function homework()
arrRadius = [5,3.5,6];%Random radii
arrArea = zeros(size(arrRadius, 2),1);%preallocate a array (column vector)
for iLoop=1:length(arrRadius)
arrArea(iLoop,1) = Circle_area(arrRadius(iLoop));
end
disp(arrArea);
end
function Ca=Circle_area(r)
Ca=pi*r^2;
end

1 件のコメント

Guillaume
Guillaume 2018 年 3 月 28 日
arrRadius = [5,3.5,6];%Random radii
sic!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2018 年 3 月 28 日

編集済み:

2018 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by