Creating Table From Excel Data

1 visualización (últimos 30 días)
Aisha Shamim
Aisha Shamim el 24 de Abr. de 2019
Respondida: Peter Perkins el 3 de Mayo de 2019
GAS = greenhousegasinventorydatadata(greenhousegasinventorydatadata.category == 'Methane')
Ireland = GAS(GAS.country_or_area == 'Ireland', 2:3)
Sweden =
Switzerland =
Poland =
subplot(2,2,1)
plot(Ireland.year,Ireland.value)
title ('Ireland')
_______________________________________________________________________________________________________________________________________
This is some sample code for loading excel data using logical indexing into a table then plotting it. However, I am just confused what the periods stand for
in certain cases like Ireland.year and GAS.country_or_area. Thanks in advance!

Respuestas (2)

Rik
Rik el 24 de Abr. de 2019
A dot can mean two things:
  1. accessing a field of a struct or a variable in a table
  2. calling a method in a class, e.g. in the syntax ax.XTicks=1:10
In your case it looks like the first.
Also note that you should use == for char arrays, as that is an element-wise operation. Use strcmp instead.

Peter Perkins
Peter Perkins el 3 de Mayo de 2019
It almost looks like you have table namednamed "greenhousegasinventorydatadata", and one of the variables in that table is called "category", and it's a categorical variable, one of whose categories is named "Methane", and you getting the subset of Methane rows into a smaller table named GAS, and another variable in "greenhousegasinventorydatadata" carried over to GAS is named "country_or_area", and it's categorical, one of whose categories is names "Ireland", and you are getting the subset of Ireland rows for two of the variables.
I say "almost", because your first line of code is a self-explanatory error if greenhousegasinventorydatadata is indeed a table.
Just guessing.

Community Treasure Hunt

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

Start Hunting!

Translated by