Exercise To The Reader
Exercise To The Reader

Reputation: 617

Plotting line graph with custom X values

I'm trying to plot the graph below

enter image description here

I'm new to GNU Octave and its syntax, I'm not able to correctly write out data points at predetermined X values. I thought writing Y as a 2-dimensional matrix would work (as long as it had the same number of columns as X) but it just made two lines instead of one, like

y = [ 0.1, 0.15, 0.2 , 0.3, ... ; 180, 40, -20, -60, ... ]

Should I write it as a set of pairs of numbers?

The only thing I got right is the X axis.

x = 0;0.5;5;

Upvotes: 0

Views: 568

Answers (1)

AndrejH
AndrejH

Reputation: 2119

You can just use the plot(x,y) function, it will draw y-values on given x-values.

x = [1,2,3,4];
y = [5,8,3,5];
plot(x,y);

Upvotes: 2

Related Questions