function mnhf_normal_shock() %MNHF_NORMAL_SHOCK plots then fits data from the normal shock table. ms = 10; % Markersize in figure. fs = 16; % Fontsize in figure. polymax = 5; % Maximum order of the approximating polynomial. % Enter data from the Normal Shock Table. Ma1 gives the (supersonic) % upstream Mach # whereas Ma2 gives the (subsonic) downstream Mach #. Ma1 = 1.00:0.08:3.00; Ma2 = [1.000 0.928 0.868 0.818 0.776 0.740 0.708 0.681 0.657 0.635 ... 0.617 0.600 0.584 0.571 0.558 0.547 0.537 0.527 0.519 0.511 ... 0.504 0.497 0.491 0.485 0.480 0.475]; % Plot the data. figure; hold on; box on plot(Ma1,Ma2,'k*','markersize',ms) set(gca,'fontsize',fs) xlabel('{\it Ma_1}, upstream Mach number') ylabel('{\it Ma_2}, downstream Mach number') title('Transonic flow through a normal shock') % Show best fit curves through data up to polynomial order polymax. for ii=1:polymax pf = polyfit(Ma1,Ma2,ii); M = linspace(min(Ma1),max(Ma1)); plot(M,polyval(pf,M),'color',[rand, rand, rand]) end % Add legend. if polymax==5 legend('tabulated data','order 1','order 2','order 3','order 4','order 5') end