Reputation: 63
I was trying to plot data. Firstly, I have load the data from a file
data = load('ex1data1.txt'); % read comma separated data
X = data(:, 1); y = data(:, 2);
m = length(y); % number of training examples
Then i have called the function plotData
function figure=plotData(x, y)
figure; % open a new figure window
if(is_vector(x) && is_vector(y))
figure=plot(x,y,'rx',MarkerSize,10);
xlabel('Profit in $10,000s');
ylabel('Population of city in 10,000s');
endif
endfunction
But Iam getting an error. which says: x is undefined Thank you in advance.
Upvotes: 0
Views: 1056
Reputation: 7995
The problem is in the following statement:
X = data(:, 1); y = data(:, 2);
you have defined X
variable but when you call
plotData(x, y)
you are using lowercase X
I think if change the statement: plotData(X, y)
will solve your problem
Upvotes: 2