1!:44 '/home/sean/ownCloud/Org/blog/Gnuplot/' load 'trig plot files csv' NB. Read the data a =: 5 }. readcsv 'DragDataSpheres.csv' 'M_data CD_data' =: 0 ". each |:(0,1){"0 1 1 a CD_Fit =: (2.1 * (^_1.2*(M_data+0.35))) + (_8.9* (^_2.2*(M_data+0.35))) + 0.92 gamma =: 1.4 term1 =. 2%gamma * *: M_data term2 =. (((*: M_data)*(*:gamma+1))%((4*gamma* *: M_data)-2*gamma-1))^gamma%gamma-1 term3 =. ((1-gamma) + 2*gamma* *: M_data)%(gamma+1) CD_Mod_Newt =: 0.5*term1*(term2*term3)-1 (|:M_data,CD_data,CD_Fit,:CD_Mod_Newt) writecsv 'Compar.csv' text =: 0 : 0 set term qt set style data points set datafile separator "," set pointsize 2 plot "Compar.csv" using 1:2 pt 6 t 'data', '' using 1:3 with lines lw 2 t 'empirical fit', '' using 1:4 with lines lt 4 lw 2 dashtype 2 t 'modified Newtonian' set ylabel 'Drag coefficient' set xlabel 'Mach number' set yrange [0:1.2] pause 10 set term png set out 'Compar.png' rep set out '' set term qt quit ) text fwrites 'testplot.gnu' 2!:0 'gnuplot < testplot.gnu'