# How to plot certain columns from a complex matrix

1 view (last 30 days)

Show older comments

##### 3 Comments

dpb
on 28 Jul 2023

### Answers (1)

Daniel
on 29 Jul 2023

Assuming that your data input is a simple matrix of double, then:

- Determine the columns you want to plot. Since I'm assuming your data input is a matrix, you should be able to count columns in the text file. (MATLAB is 1-based, so the first column is column 1.)
- plot(data(:,[column1 column2 column3 column4 column5 column6]))
- legend('Entry 1','Entry 2','Entry 3','Entry 4','Entry 5','Entry 6')

Example below.

data = rand(100,10)+[1:10];

plot(data(:,[1 3 5 7 9 2]))

legend('Random entries 1','Random entries 3','5','7','9','2')

If that doesn't work on your input data, then please share the commands you're using to import your data, and/or the data type. You can get the data type with the class command, e.g.

class(data)

My data is simple numbers so it has the underlying data type double, but there are quite a few different ways you can import data, with different resulting data types.

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!