Reputation: 94950
I have
a =
54.1848
50.0456
99.9748
83.1009
63.1457
91.7577
64.0805
48.2090
75.7711
t =
79.7077
31.0913
14.9389
10.8303
16.4844
26.8465
41.6946
77.3369
186.3246
How can make a simple line plot with a
on y axis
and t
on x axis
?
plot (a,t)
gives
and plot (t,a)
gives
I don't understand how these are generated. The result should be something else.
Upvotes: 2
Views: 1929
Reputation: 24823
[t_sorted, index] = sort(t);
plot(t_sorted, a(index));
is the most efficient way to do this.
Or, if you don't really care for having the lines you can simply use:
plot(t,a,'rx')
Upvotes: 7
Reputation: 2759
I think that if you sort both vectors according to the values in t
and then use plot(t,a)
you will get what you want.
Upvotes: 3