0

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??

0

1 Answer 1

2

Sort a and plot b using the indices of the sorted version of a:

[asorted ind] = sort(a);
 plot(asorted,b(:,ind));
1
  • 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 ???
    – om mustafa
    Commented May 2, 2011 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.