MATLAB Project Help

I'm having a lot of trouble with this MATLAB class mainly because the professor doesn't know how to teach. Here's the program:

P2.7 & P2.8 Project P2.6 provided a table of pressure, p, temperature, T,and density, rho every 1000 meters of altitude. Atmospheric property
values at altitudes between table values can be determined by linear
interpolation. The linear interpolation formula is as follows:


where y represents an atmospheric property (pressure, temperature and
density) to be determined, z is the altitude at which the unknown property is to be determined, z1 and z2 are the nearest altitudes enclosing z, y1 and y2 represent a particular property (either pressure, temperature or density) at z1 and z2 respectively. The atmospheric properties of pressure, temperature and density are to be determined at the following altitudes: 5170m, 8435m, 13320m, 22250m, 34370m, 48550m and 64220m. Construct a MATLAB program that will do the following.
1. In the main program, load output2.dat into the workspace.
2. In the main program enter the specified altitudes at which atmospheric properties are to be determined as a row vector.
3. For each specified elevation use a proper for loop and a compound if
statement to determine the closest interval containing the specified
altitude. Print out the properties of pressure, temperature and density at the beginning (state 1) and end (state 2) of the selected interval.
4. Construct a self written function, interp, with input arguments (z, z1, z2, y1, y2) that will determine by linear interpolation the value of y at altitude z and return value y to the main program.
5. In the main program call the interp function (three times for each
specifed altitude, one for temperature, one of pressure and one for
6. Print out a table containing 4 columns, (specified altitude, pressure,
temperature and density at the specified altitudes).

The previous program is attached, I just need to expand on how to use the interpolation equation into the program. [b]Please help, I can PAY![/b][u][/u] IF YOU CAN HELP, PLEASE EMAIL ME BACK AT [u][/u]. Thanks.


function ProjectNo3
clear; clc;
load output2b.txt

zt=output2b(:,1); %The four columns of data
z=[5170 8435 13320 22500 34370 38550 44220]; %Specified altitude
p=interp1(zt,pt,z); %Interpolating the values

fo=fopen('outputnew.dat','w'); %Opening new .dat folder
fprintf(fo, 'Specified Altitude(m) Temperature(K) Pressure(Pa) Density(K/m)
') %Labels
fprintf(fo, '------------------------------------------------------------------------------------------
for a=1:7
fprintf(fo, ' %5.2e %5.2e %10.2e %5.2e

plot(zt,pt); %Solid lines are standard
xlabel('zt(m)'), ylabel('pt(Pa)'), title('Altitude vs. Pressure'), grid, figure; %This graphs the 3 figures
xlabel('zt(m)'), ylabel('Tt(K)'), title('Altitude vs. Temperature'), grid, figure;
xlabel('zt(m)'), ylabel('Rt(K/m)'), title('Altitude vs. Air Density'), grid

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!