Hi,
I am doing a MATLAB related course and came up with this question (attachment), which i couldn't solve by myself. Answers with explanation would really be helpfull.
Thanks.

1 件のコメント

Raj
Raj 2024 年 1 月 5 日
After running memory, the output is the following:
Which of the following arrays require more than the available memory? (Select all that apply.)

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

 採用された回答

Walter Roberson
Walter Roberson 2023 年 9 月 5 日

3 投票

Suppose you have rand(1,1e8) . Then the resulting array will have 1 * 1e8 locations in it, and each one of them will be a double. A double needs 8 bytes, so 1e8 locations would require 8e8 bytes of memory. The available memory is over 1e10 so 8e8 bytes would fit.
Suppose you have rand(1e3) . Then this is not a 1e3 x 1 array, and it is not a 1 x 1e3 array !
It is an oddity of MATLAB then when you pass a scalar to rand() or randn() or zeros() or ones() [or some other functions], that the interpretation is that you are asking for a square array with that size on each side. So rand(1e3) is asking for a 1e3 by 1e3 array. Which would be 1e3*1e3 = 1e6 locations. Each location takes 8 bytes, so that would require 8e6 bytes. The available memory is over 1e10 so 8e6 bytes would fit.
Using this reasoning, you should be able to systematically figure out which of the arrays will fit in just over 1e10 bytes of memory.

1 件のコメント

Gopinath Tamilmaran
Gopinath Tamilmaran 2023 年 9 月 5 日
Hi Walter,
Thanks for the detailed response. I have got the correct answer which is options c) and e).

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by