フィルターのクリア

extract letters in country name

2 ビュー (過去 30 日間)
Ileana Gonzalez
Ileana Gonzalez 2018 年 9 月 30 日
コメント済み: Ileana Gonzalez 2018 年 9 月 30 日
The file contains a 10-by-1 structure array called S. The 10 elements in S correspond to 10 different countries, whose name, GDP per capita (in USD), population and land area (in square kilometers) are stored in different structure fields. For example, S(1) leads to the output
ans =
struct with fields:
CountryName: ChinaGDP: 8643
Population: 1.4095e+09 Area: 9326410
In one line of code, extract the first 3 letters of the name of the 4th country stored in S and save it to a string called country4. I don't know how to do this. SO i have an idea of something like S(4,1) but there where would i include the (1:3) to extract just the three letters? I just need guidance i really want to learn this no answers Thanks.
  1 件のコメント
Steven Lord
Steven Lord 2018 年 9 月 30 日

Take a look at this documentation page.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2018 年 9 月 30 日
It's not S(4,1), it's S(4) and then you need the field name, CountryName, and it's the CountryName that takes the index 1:3. Try it. Experiment around. If you still need help with your homework, write back.
  1 件のコメント
Ileana Gonzalez
Ileana Gonzalez 2018 年 9 月 30 日
Actually jk I got it!! thanks!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by