i have two arrays to plot , array a[1,5] in x axis and array b[4,5] in y axis . i used plot(a,b), The problem is that the elements of array a are not ordered so when the graph is drawn it connect between points in the same order of the array elements so the graph line once go right and anothor left and so, also i want it to be in a curve shape??
1 Answer
Sort a
and plot b using the indices of the sorted version of a
:
[asorted ind] = sort(a);
plot(asorted,b(:,ind));
-
i already did this but i want the graph to be in curve shape so i used [s ind]=sort(positions); r=rec_Power(:,ind);xx = 0:.001:s(4); yy = spline(s,r,xx); plot(s,r,xx,yy); and i got the curve but with wrong values i.e negative values ,although there's no element in both arrays is negative ??? Commented May 2, 2011 at 7:54