Is my code for this assignment correct?

1 visualizzazione (ultimi 30 giorni)
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}

Risposta accettata

Voss
Voss il 7 Dic 2022
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'

Più risposte (0)

Tag

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by