Plotting lines between data points on a graph - PROBLEM!

7 ビュー (過去 30 日間)
Ivan
Ivan 2012 年 3 月 6 日
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 3 月 6 日
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>)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by