:Matlab program with these equations

  • Thread starter Thread starter armin11
  • Start date Start date
  • Tags Tags
    Program
Click For Summary

Discussion Overview

The discussion revolves around writing a MATLAB program to calculate and plot various parameters related to oblique shocks in air, specifically focusing on the relationships between the deflection angle (θ), shock angle (β), Mach number (M2), and pressure ratios (p2/p1, p02/p01). Participants seek assistance in translating mathematical equations into MATLAB code.

Discussion Character

  • Technical explanation
  • Homework-related
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant requests help in writing a MATLAB program using specific equations related to oblique shocks.
  • Another participant suggests that variable names in the MATLAB code should be clarified and provides a hint about using ellipses for line continuation in MATLAB.
  • A different participant expresses confusion about defining variables like M1 and β, indicating a lack of clarity on how to implement the equations in code.
  • One participant recalls having written a similar code previously and suggests assuming a range of angles and Mach numbers to find solutions.
  • Another participant notes the difficulty in solving non-linear equations and suggests that numerical methods may be necessary, referencing MATLAB's Optimization toolbox.
  • One participant encounters an error stating that the system is inconsistent when trying to solve the equations with MATLAB's 'solve' function, indicating potential issues with the equations themselves.
  • Several participants express gratitude for the assistance provided, indicating that some responses were helpful.

Areas of Agreement / Disagreement

Participants generally agree that the equations are complex and may require numerical methods for solutions. However, there is no consensus on the specific approach to take or the exact implementation in MATLAB.

Contextual Notes

Participants mention challenges with defining variables and solving non-linear equations, indicating that the equations may not be straightforward to implement in MATLAB without additional mathematical considerations.

armin11
Messages
66
Reaction score
0
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)]
 
Physics news on Phys.org


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.
 


armin11 said:
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
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?
 
  • #10


Thanks Boss

That is off great help.

SIRCORP
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K