Is my code for this assignment correct?

조회 수: 1 (최근 30일)
Eduardo Gallegos
Eduardo Gallegos 2022년 12월 7일
댓글: Eduardo Gallegos 2022년 12월 7일
Hi everyone, I'm unsure if this the correct way to do what the assignment is asking.
ASSIGNMENT
Make a cell array called South_American_Countries.
You can find a link to these countries at List of South American CountriesLinks to an external site.
In this list, the countries to put in your cell array are called "Sovereign states".
Do not include the territories, which are listed below the Sovereign states.
The add this code to display the 3rd and 7th countries in your cell array:
South_American_Countries{3} % Note that you need squiggly brackets to access members of a cell array.
South_American_Countries{7}
(If your cell array has a different name, use that name.)
CODE
Soverign_States = cell (1,11)
Soverign_States(1,1) = cellstr('Argentina')
Soverign_States(1,2) = cellstr('Bolivia')
Soverign_States(1,3) = cellstr('Brazil')
Soverign_States(1,4) = cellstr('Chile')
Soverign_States(1,5) = cellstr('Colombia')
Soverign_States(1,6) = cellstr('Ecuador')
Soverign_States(1,7) = cellstr('Guyana')
Soverign_States(1,8) = cellstr('Peru')
Soverign_States(1,9) = cellstr('Suriname')
Soverign_States(1,10) = cellstr('Uruguay')
Soverign_States(1,11) = cellstr('Venezuela')
Soverign_States{1,1}
  댓글 수: 2
Voss
Voss 2022년 12월 7일
You forgot Paraguay.
Eduardo Gallegos
Eduardo Gallegos 2022년 12월 7일
Thank you for checking my work.

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

채택된 답변

Voss
Voss 2022년 12월 7일
You can construct a cell array more directly than that (which is not to say your approach is "incorrect"):
S = {'Argentina' 'Bolivia' 'Brazil'} % etc.
S = 1×3 cell array
{'Argentina'} {'Bolivia'} {'Brazil'}
S{3}
ans = 'Brazil'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by