om mustafa
om mustafa

Reputation: 13

matlab - graph plotting

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

Upvotes: 0

Views: 173

Answers (1)

Itamar Katz
Itamar Katz

Reputation: 9645

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

[asorted ind] = sort(a);
 plot(asorted,b(:,ind));

Upvotes: 2

Related Questions