1
votes

I need your help again :). I'm trying to plot multiple lines for a very large dataset. To start easier, I divided the dataset to get a TABLE in Matlab that contains 6 columns, with the first column representing the date that I want on my x-axis. Now I want to plot the other columns (and in the original file are a lot more than 6 columns) on the y axis, using a for loop. I tried the following, with no success:

hold on
for i=2:1:6
  plot(Doldenstock(:,1), Doldenstock(:,i));
end
hold off

As I understand this, this code would do exactly what I want for columns 2,3,4,5,6. However, I always get the same error code:

Error using tabular/plot Too many input arguments.

Error in Plotting_bogeo (line 6) plot(Doldenstock(:,1), Doldenstock(:,i));

Now, I don't know if maybe for loops like this don't work for tabes but only for arrays?

Thanks for your help in advance!

Cheers, Tamara

1

1 Answers

2
votes

The function plot(x) expect x to be a scalar, a vector, or a matrix. But in your case the input is a table, because accessing a table with parentheses return a table, which is not supported.

If you read the doc "how to access data in a table" you will figure out that you need to use curly brace {} to extract the raw data (in your case a 1D matrix).

So use:

plot(T{:,1},T{:,2})