MATLAB Answers

plot columns of a table

3,080 views (last 30 days)

How do I plot two of the columns of my table?

I have a table "t" with variable (column) names "x" and "y". How do I plot these variables as plot(x,y)?

>> t = table([2 4 5]', [7 3 5]', 'VariableNames', {'x','y'});

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 May 2018
This can be done by accessing the data of the table. The following link details how you can extract data from a table:
The method below uses Dot Indexing.
>> plot(t.x, t.y);

  1 Comment

Matteo Soldini
Matteo Soldini on 7 Feb 2020
What should I write if I need for example four plots with the same variable on the x-axis and four different variables on the y-axis?

Sign in to comment.

More Answers (0)

Sign in to answer this question.