Plot 2 arrays in matlab?

16 ビュー (過去 30 日間)
Umesh
Umesh 2013 年 4 月 10 日
lets assume I have two arrays a & b as follows: a=[1,2,5,3,1.5,7,6]; b=[12,1,45,11,3,2,65];
plot(a,b) gives a plot having so many intersecting line segments. How can one get a continuous curve with no intersecting segments? Something like plotting those points first and drawing segments as we proceed along a axis. Thank you for any help you can offer.

採用された回答

Jonathan Epperl
Jonathan Epperl 2013 年 4 月 11 日
You need to sort you a array, then permute b the same way. Concretely:
help sort
% Then you'll understand why:
[as,is] = sort(a);
plot(as,b(is),'r-',a,b,'x');
  1 件のコメント
Umesh
Umesh 2013 年 4 月 11 日
thanks man!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by