% matlab code to plot data generated by ex2.gms % loads the data file ex2.dat into a matrix ex2. load ex2.dat % move it to A A = ex2; % take x to be first col of A, and let n be number of points. x = A(:,1); n = size(A,1); figure(1); h = plot(x,A(:,2),x,A(:,3),x,A(:,4),x,A(:,5)); % figure out axes scaling - find largest and smallest data elements ymin = min(min(A(:,2:5))); ymax = max(max(A(:,2:5))); % add some padding in the Y direction diff = ymax - ymin; ymin = ymin - .1*diff; ymax = ymax + .1*diff; axis([x(1) x(end) ymin ymax]); % label the axes xlabel('Time'); ylabel('A'); % make a cute legend, and add a title legend(h,'a','b','c','d',0); title('Example 2: Plot of GAMS data in Matlab');