Determining arrays require more than the available memory

how do you precisely determine if a code of array creation will exceed the limit of the computer?
after running memory function in matlab, the following results came:
  • maximum possible array : 9678 MB
  • memory available to all arrays: 9678 MB
  • memory used by matlab: 5705 MB
  • RAM: 16218 MB
Which of the following arrays require more than the available memory? (Select all that apply. - taken from Matlab Programming techniques):
  • x = randn(1,1e9); [Memory required: 1e9 elements * 8 bytes/element = 8 GB]
  • x=ones(1e4); [Memory required: 1e4 elements * 8 bytes/element = 0.08 MB]
  • x=zeros(1e5); [Memory required: 1e5 elements * 8 bytes/element = 0.8 MB]
  • x=2*randn(1,1e9); [Memory required: 1e9 elements * 8 bytes/element = 8 GB]
  • x= [randn(1,1e9); randn(1,1e9)]; [Memory required: 2 (number of rows) * 1e9 elements/row * 8 bytes/element = 16 GB]
I tried calculating the the amount of bytes needed for each option, but i dont seem to fully grasp this concept, as none of the option i select is correct.
thanks in advance.

4 件のコメント

Jasmitha
Jasmitha 2023 年 12 月 26 日
移動済み: Dyuman Joshi 2023 年 12 月 26 日
After running memory, the output is the following:
Which of the following arrays require more than the available memory?
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 26 日
@Oren Savir, the number of elements for arrays created via ones() and zeros() are incorrect.
When you provide a singular value, say N, to the aforementioned functions, the output is an NxN array. See - zeros and ones.
Thus the number of elements is N^2 instead of N.
M
M 2024 年 1 月 10 日
Which of the following arrays require more than the available memory? (Select all that apply.)
x = randn(1,1e9);
x = ones(1e4);
x = zeros(1e5);
x = 2*randn(1,1e9);
x = [randn(1,1e9); randn(1,1e9)];
Steven Lord
Steven Lord 2024 年 1 月 10 日
What do you think the answer is and why do you think each of those arrays would or would not require more than the available memory? If you tell us your reasoning we could confirm that you're correct or explain why you're incorrect.

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

回答 (1 件)

カテゴリ

製品

リリース

R2023a

質問済み:

2023 年 9 月 5 日

コメント済み:

2024 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by