Plotting lines between data points on a graph - PROBLEM!

5 visualizaciones (últimos 30 días)
Ivan
Ivan el 6 de Mzo. de 2012
im facing a problem of plotting a line between points plotted on a graph. below is my code. only points appear but not the line connected them. Why is this so? This code is within a FOR loop, is that why it doesnt work?
if ((cx>=10)&(cx<=60)&(cy>=10)&(cy<=60))
figure(2);
title('Graphical Results');
hold on;
plot(j, diameter(j), 'ro-', 'LineWidth', 2, 'MarkerEdgeColor', 'k', 'MarkerFaceColor', 'g', 'MarkerSize', 10)
ylabel('Diameter of pupil');
xlabel('Frame');
hold off;
set(gcf, 'Position', get(0, 'ScreenSize'));
fprintf(1,'#%3d %11.1f %8.1f\n', j, diameter(j), area);
end
below is the graph i am getting...
you realised there isnt a line connected it.. i have tried many combinations but nothing works.

Respuestas (1)

Walter Roberson
Walter Roberson el 6 de Mzo. de 2012
Unless you supply at least two X and two Y coordinates to plot(), all it can do is draw the one point you give it.
You would be better off storing the j values until the end of the loop, and then
plot(Jlist, diameter(Jlist), 'ro-' <etc>)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by