midterm1b_solution - P =[1.63 1.96 2.37 3.00 3.96%pressure...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Computational Physics Phy 265 Midterm 1b (In-Class) Solution %GAS - A script to plot V vs. T/P data from an ideal gas law experiment, %fit a straight line to the data, and determine the ideal gas constant R. %File written by S.C. Tegler. Last modified 2/21/11 %--------------------------------------------------- n = 0.05; %number of moles of gas V = [0.75 0.65 0.55 0.45 0.35]; %volume data in liters T = [25 37 45 56 65]; %temperature data in Celsius
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P = [1.63 1.96 2.37 3.00 3.96]; %pressure data in atmospheres T = T + 273.15; %convert celsius to kelvin TdivP = T./P; %calculate T/P using data p = polyfit(TdivP,V,1); %find slope, intercept of best fit line Vfit = polyval(p,TdivP); %best fit volumes plot(TdivP,V, 'sk' ); %begin plotting hold on ; plot(TdivP,Vfit, '-r' ); xlabel( 'T/P' ); ylabel( 'V' ); title( 'Ideal Gas Experiment' ); %end plotting R = p(1)/n %print R to command window...
View Full Document

This note was uploaded on 02/23/2012 for the course PHYSICS 265 taught by Professor Tegler during the Spring '11 term at N. Arizona.

Ask a homework question - tutors are online