Multipline plotting

2 ビュー (過去 30 日間)
Jürgen
Jürgen 2012 年 2 月 13 日
Hello,
I need to plot over 3000 line segments on a figure, normally I use a loop
close all A=[1 2 3 4;2 8 9 10;5 6 7 1; 8 5 2 1]% example matrix
figure
hold on
for counter=1:size(A,1) X= [A(counter,1) A(counter,3)]; Y= [A(counter,2) A(counter,4)]; line(X,Y) end
but since I have the coordinates in one matrix it seems not efficient to use loop for the plotting. Is there another way of is this just the way to go? I already consulted this thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/240110 , so I thought using a loop is inevitable
thanks for any input

採用された回答

Laura Proctor
Laura Proctor 2012 年 2 月 13 日
X = [ A(:,1) A(:,3) ]';
Y = [ A(:,2) A(:,4) ]';
line(X,Y,'color','b')

その他の回答 (1 件)

Jürgen
Jürgen 2012 年 2 月 13 日
ok, this was stupid of me, tried that solution but forgot to transpose, sorry, THANKS

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by