Is my code for this assignment correct?

1 次查看(过去 30 天)
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}

采纳的回答

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 中查找有关 Startup and Shutdown 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by