% matlab code to plot data generated by ex1.gms % fancier plot, with every 5th data point indicated. % load data from ex1.dat into the matrix ex1 load ex1.dat % use spconvert to create a matrix A, with ordinate (X axis) as first col, % and the four abscissae as 2nd, 3rd, 4th, 5th columns. A = spconvert(ex1); % add the required shift to get x x = 1990:1990+size(A,1)-1; % make this Figure 1 figure(1); % form reduced versions of the abscissae and ordinates, including only % every 5th data point xred = x(1:5:41); Ared = A(1:5:41,:); % plot each line twice - first a continuous line, then mark every 5th % data point with an x, o or whatever. hred = plot(x,A(:,1),'y-', ... x,A(:,2),'g-', ... x,A(:,3),'c-', ... x,A(:,4),'b-'); hold on; plot(xred,Ared(:,1),'yo', ... xred,Ared(:,2),'gx', ... xred,Ared(:,3),'cd', ... xred,Ared(:,4),'b.'); % reduce te vector of handles so that hred points only to the solid lines % (which are the ones we want to label in the legend). % hred= h(1:2:7); % fix the ranges on the X and Y axes axis([x(1) x(41) 0 5]); xlabel('Time'); ylabel('A'); % make a legend, "0" allows Matlab to choose its location legend(hred,'a','b','c','d',0); title('Example 1b: Plot of GAMS data in Matlab');