Path: blob/master/Week 2/Programming Assignment-1/plotData.m
626 views
function plotData(x, y)1%PLOTDATA Plots the data points x and y into a new figure2% PLOTDATA(x,y) plots the data points and gives the figure axes labels of3% population and profit.45figure; % open a new figure window67% ====================== YOUR CODE HERE ======================8% Instructions: Plot the training data into a figure using the9% "figure" and "plot" commands. Set the axes labels using10% the "xlabel" and "ylabel" commands. Assume the11% population and revenue data have been passed in12% as the x and y arguments of this function.13%14% Hint: You can use the 'rx' option with plot to have the markers15% appear as red crosses. Furthermore, you can make the16% markers larger by using plot(..., 'rx', 'MarkerSize', 10);1718%data = load('ex1data1.txt'); % read comma separated data19%X = data(:, 1); y = data(:, 2);20%m = length(y); %training_examples21figure(1);22plot(x, y, 'rx', 'MarkerSize', 10); % Plot the data, rx = red marker23ylabel('Profit in $10,000s'); % Set the y-axis label24xlabel('Population of City in 10,000s');2526% ============================================================2728end293031