How to plot multiple columns from data set in matlab

98 visualizaciones (últimos 30 días)
abdel
abdel el 24 de Sept. de 2017
Respondida: KSSV el 25 de Sept. de 2017
I have a 63 by 281 matrix, the rows of last column has values of 1 and 2. I would like to plot all culumns like this:
num = xlsread('LabeledData.xlsx');
X = num(:, 1:280);
y = num(:,281);
plot(X(y == 1, 1), X(y == 1, 2), 'ro');
hold on;
plot(X(y == 2, 1), X(y == 2, 2), 'bx');
The above plots will only plot the the first two columns, is there an alternative way of plotting all of columns instead of doing it explicitly likes this
plot(X(y == 1, 1), X(y == 1, 2), X(y == 1, 3), X(y == 1, 4),, X(y == 1, 5), ..., X(y == 1, 280) 'ro');

Respuestas (1)

KSSV
KSSV el 25 de Sept. de 2017
x = (1:100)' ;
y = rand(100,10) ;
% plot all once
plot(x,y)
%%or loop
figure
hold on
for i = 1:10
plot(x,y(:,i))
end

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by