필터 지우기
필터 지우기

Plot 2 arrays in matlab?

조회 수: 2 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by