MATLAB Project Help - Programmers Heaven

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# MATLAB Project Help

Posts: 1Member
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:

y=y1+(z-z1)*(y2-y1)/(z2-z1)

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
density).
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][email protected][/u]. Thanks.

_____________________________________________________________________

function ProjectNo3
clear; clc;

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

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
',z(a),T(a),p(a),R(a));
end

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

fclose('outputnew.dat')