I have a simple data file looking like this:
data.txt
34.62365962451697,78.0246928153624,0
30.28671076822607,43.89499752400101,0
35.84740876993872,72.90219802708364,0
60.18259938620976,86.30855209546826,1
79.0327360507101,75.3443764369103,1
And I am trying to plot its data using the following code:
data = load('data.txt');
X = data(:, [1, 2]); y = data(:, 3);
plotData(X, y);
hold on;
xlabel('Exam 1 score')
ylabel('Exam 2 score')
legend('Admitted', 'Not admitted')
hold off;
pause;
However this bring me the following errors:
warning: legend: plot data is empty; setting key labels has no effect
error: legend: subscript indices must be either positive integers less than 2^31 or logicals
And nothing gets plotted.
I don't understand what's wrong. The working directory is fine in octave.
How can I fix this?
Many thanks
legend({'Admitted', 'Not admitted'}).Xandy? Are they really empty? Also, try using csvread instead of load. Load is for matlab variables stored in files.plotDatais not a standard octave function, look at that. Sub plot for it and it works.