# :Matlab program with these equations

urgent:Matlab program with these equations

Question:For an oblique shock in air, write a computer program to calculate and plot β , M2 ,p2/p1,p02/p01 versus M1 for various θ . Show the Mach wave and normal shock wave limits and the line of maximum deflection angle on the plot.

I've written the below equations but i can't write a program in MATLAB to use these,please help me.

equations:
(in the below equations: a=θ , s=β ,gam=1.4)
cot(a) = tan(s) * [{((gam+1) * M^2)/(2 * M^2 * sin^2(s) - 1)} - 1]

M1^2 * sin^2(s -a) = [(gam-1)M^2 sin^2(s) + 2] / [2 * gam * M^2 * sin^2(s) - (gam -1)]

p02 / p01 = {[(gam + 1) * M^2 * sin^2(s)]/[(gam-1)*M^2 * sin^2(s) + 2]}^[gam/((gam-1)] * {(gam+1)/[2 * gam * M^2 * sin^2(s)-(gam-1)]}^[1/(gam-1)]

p2/ p1 = [2 * gam * M^2 * sin^2(s)-(gam -1)] / (gam + 1)

(M2*sin(a-s))^2=[(1+(gam-1/2)*(M1*sin(a))^2)/(gam*(M1*sin(a))^2-(gam-1)/2)]

Are these equations exactly what you wrote in Matlab? If so then your variable names are wrong. Use names like Cot_a and Po2_Po1.

Also a hint in matlab, is that you can use an ellipses "..." to extend your equation to another line.

Code:
 A = add_1 + add_2 + add_3 + add_4 + ...
add_5 + add_6

No,these are not the codes that i wrote in MATLAB and "cot" means cotangent and is not a variable,my problem is that i don't know how to define these variables,for example we have only theta=[0:0.01:2*pi] then we have M1 and betha undefined but we have their formulas,how can I write a code for these?!

About a year ago I wrote a code similar to this, if not, exactly the same. I can't find the code now, however, from what I remember, you simply have to assume a range of angles and Mach numbers and hope your solution lies somewhere in that range. If not, just keep going until it does. You can make a look up table also.

It doesn't work,No one to help?!!!

Matlab: Air in water

Can some one direct me to right place. : This is what I wish to do

Hot Air is bubbled through water. Water is contained in a tank which is cold to start with. Hot air is bubbled through this tank(from bottom inlet uniformly distributed using a sparger)

I wish to develop an MATLAB model how hear gets transferred from AIR to WATER. AIR is continuously flowing and water is in normal condition but Water to Air ratio is around 60% which means at any given time 30% space is taken by AIR int he entire tank.

At the top Air is Escaping from the Tank to atmosphere and tank is not under any pressure.

MATLABdude

It doesn't work,No one to help?!!!

The problem is that you're trying to solve systems of non-linear equations. If I read correctly, your first two equations can be used to solve for beta ($\beta$) and M (not sure if that's M1 or M2), for a given theta ($\theta$).

Based on a cursory look at the equations, you'll probably have to use numerical methods to solve these. There is some of this in the Optimization toolbox, but the point of your homework is to probably code your own. Nevertheless, a bit of a starting point:
http://www.chemeng.queensu.ca/courses/CHEE222/Matlab/OnlineTutorial2.pdf [Broken]
http://www.mathworks.com/help/toolbox/optim/ug/fsolve.html

Last edited by a moderator:

thanks buddy,this helps a lot :D

When i try to solve the equations with 'solve' it gives this error:System is inconsistent. Solution does not exist.
Apparently the usual equation solvers doesn't work on this and it needs something more mathematical,who knows how to fix this?

Thanks Boss

That is off great help.

SIRCORP