2

i'm fairly new to matlab and i'm looking for a way to evaluate data in a table. There's an excel table as illustration attached.

My measurements are savedin a txt-file divided by cycle numbers. All data is in one table though. Eventually i want to divide the data in the table in a way that i can select/use/plot the data from all columns depending on their cycle number.

E.g. plotting R and I values of cylce 2 against each other.

What's the best way to do that? I heard of timeseries, didn't find the right material online to get my head behind it yet though.

Thanks and cheers!

table for illustration

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Alexander K
  • 137
  • 1
  • 1
  • 8

1 Answers1

2

You only need a table. There are several ways to extract a column from a table. The simplest way is to use a dot with the name of the column. If the column has numerical values, this gives you the corresponding numerical vector.

To select some values of those vectors you can use logical indexing:

t = table; % crete empty table
t.R = [5 6 7 12 13 14 20 21 22].'; % create and fill a column of the table
t.I = [1 2 3 6 8 9 8 7 6].';
t.Cycle_Number = [1 1 1 2 2 2 3 3 3].';
ind = t.Cycle_Number==2; % logical index
plot(t.R(ind), t.I(ind))

To directly create the table from data contained in a file you can use readtable.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147