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

Hi Walter,
Thanks for the detailed response. I have got the correct answer which is options c) and e).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2022b

태그

질문:

2023년 9월 5일

댓글:

Raj
2024년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by