Plot 2 arrays in matlab?

28 views (last 30 days)
Umesh on 10 Apr 2013
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.

Accepted Answer

Jonathan Epperl
Jonathan Epperl on 11 Apr 2013
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);
  1 Comment
Umesh on 11 Apr 2013
thanks man!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!