Is my code for this assignment correct?

1 Ansicht (letzte 30 Tage)
Eduardo Gallegos
Eduardo Gallegos am 7 Dez. 2022
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 Kommentare
Voss
Voss am 7 Dez. 2022
You forgot Paraguay.
Eduardo Gallegos
Eduardo Gallegos am 7 Dez. 2022
Thank you for checking my work.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Voss
Voss am 7 Dez. 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'

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by