Matlab Problem with Ideal Gas Law

```I am working on a problem for engineering with MATLAB and the ideal
gas law but am having trouble. This is my 3rd time using MATLAB so
bare with me.

here are the two problems, A seems to be working fine, its B im having
trouble with.

Calculate T with:
a. 10 values of pressure from 0 bar to 400 bar for volume 1L
b. 10 values of volume from .1L to 10L for a pressure of 220 bar.

Heres my code:
% --- INPUTS ---
Pa=linspace(0,400,10) % pressure for part a - measured in bar
Va=1 % volume for part a - measured in L
n=2 % number of moles
R=.08314472 % ideal gas constant - measured in L bar/K mol
a=5.536 % measured in L^2bar/mol^2
b=.03049 % memasured in L/mol
Pb=220 % pressure for part b - measured in bar
Vb=[.1:1.1:10]

% --- CALCULATIONS ---
Ta=((Pa+(n^2*a/Va^2))*(Va-(n*b)))/(n*R) % Temperature calculation for
part a
Tb=((Pb+(n^2*a/Vb^2))*(Vb-(n*b)))/(n*R) % Temperature calculation for
part b

Thanks in advance for the help guys!
```
 0
1/27/2010 3:32:10 AM
comp.soft-sys.matlab 208218 articles. 7 followers. lunamoonmoon (258) is leader.

4 Replies
483 Views

Similar Articles

[PageSpeed] 19
```On Jan 26, 10:32=A0pm, Trent Renier <lildevil111...@gmail.com> wrote:
> I am working on a problem for engineering with MATLAB and the ideal
> gas law but am having trouble. This is my 3rd time using MATLAB so
> bare with me.
>
> here are the two problems, A seems to be working fine, its B im having
> trouble with.
>
> Calculate T with:
> a. 10 values of pressure from 0 bar to 400 bar for volume 1L
> b. 10 values of volume from .1L to 10L for a pressure of 220 bar.
>
> Heres my code:
> % --- INPUTS ---
> Pa=3Dlinspace(0,400,10) % pressure for part a - measured in bar
> Va=3D1 % volume for part a - measured in L
> n=3D2 % number of moles
> R=3D.08314472 % ideal gas constant - measured in L bar/K mol
> a=3D5.536 % measured in L^2bar/mol^2
> b=3D.03049 % memasured in L/mol
> Pb=3D220 % pressure for part b - measured in bar
> Vb=3D[.1:1.1:10]
>
> % --- CALCULATIONS ---
> Ta=3D((Pa+(n^2*a/Va^2))*(Va-(n*b)))/(n*R) % Temperature calculation for
> part a
> Tb=3D((Pb+(n^2*a/Vb^2))*(Vb-(n*b)))/(n*R) % Temperature calculation for
> part b
>
> Thanks in advance for the help guys!

Sorry for not stating my error, im gettin an error that my matrix must
be square for the first part of the B equation. I dont know how to fix
this..
```
 0
1/27/2010 3:33:58 AM
```Trent Renier wrote:
....

> Sorry for not stating my error, im gettin an error that my matrix must
> be square for the first part of the B equation. I dont know how to fix
> this..

Look at  ./, .*, etc., ...

Consider what * or / mean in matrix terms (look their description up as
well)...

--
```
 0
none1568 (7453)
1/27/2010 3:42:38 AM
```On Jan 26, 10:42=A0pm, dpb <n...@non.net> wrote:
> Trent Renier wrote:
>
> ...
>
> > Sorry for not stating my error, im gettin an error that my matrix must
> > be square for the first part of the B equation. I dont know how to fix
> > this..
>
> Look at =A0./, .*, etc., ...
>
> Consider what * or / mean in matrix terms (look their description up as
> well)...
>
> --

I have read through that prevously and understand the dot functions
but i just dont grasp where they go or how to make it all work
together.
```
 0
1/27/2010 5:01:28 AM
```Trent Renier wrote:
> On Jan 26, 10:42 pm, dpb <n...@non.net> wrote:
>> Trent Renier wrote:
>>
>> ...
>>
>>> Sorry for not stating my error, im gettin an error that my matrix must
>>> be square for the first part of the B equation. I dont know how to fix
>>> this..
>> Look at  ./, .*, etc., ...
>>
>> Consider what * or / mean in matrix terms (look their description up as
>> well)...
>>
>> --
>
> I have read through that prevously and understand the dot functions
> but i just dont grasp where they go or how to make it all work
> together.

You need them where you want element-by-element operations as opposed to
matrix manipulations...

--
```
 0
none1568 (7453)
1/27/2010 5:16:34 AM
Similar artilces about - Matlab Problem with Ideal Gas Law:

Problems with dvips in Miktex 2.5
Hello, I've upgraded to MiKTeX 2.5 and I am having problems with dvips and included eps figures which weren't present when running under MiKTeX 2.4. I've tried checking the dvips manual to see if I can fix this myself but with no success. Here's the output from a failed run under 2.5: This is dvips(k) 5.95b Copyright 2005 Radical Eye Software (www.radicaleye.com) ' TeX output 2006.08.06:1543' -> THESIS.ps dvips.exe: Font Times used in file hdaout.eps is not in the mapping file. dvips.exe: Font Times used in file fuzzpart.eps is not in the mapping file. dvips.e...

MATLAB's SOUND() function in C
Is there a way to implement MATLAB's sound function under C? For those who don't use MATLAB, it's essentially a simplistic, static, mono sound function that converts a series a numbers into a sound at a given sampling rate. nothing fancy. all the Sound APIs begin by discussing all the fancy drivers and buffers and crazy shit i don't really care about. Thanks. In article <1151779016.882805.282580@d56g2000cwd.googlegroups.com>, sluox@yahoo.com wrote: > Is there a way to implement MATLAB's sound function under C? > > For those who don'...

Problem with Query #2
I use "wrkqry" for build some query. Please help me . How I can use "IIF" in "Define Result Field" Regards Czarek hmmmm, if I understand your question correctly, and you mean putting an IF in "Define Result Field", I don't think you can. How about defining a field here (giving it a name and using SUBSTR or whatever) then in "Select Records" refer to the defined field? Not sure if this is what you are looking for, but......... Regards John hmmmm, I'm not 100% sure what you are looking for, but if you mean using IF in "Define R...

How do you do ARIMA in matlab?
Hi, (Sorry for cross-posting) I am clueless w.r.t using matlab for time series. I have a time series and I would like to make estimates of future using the past. How do I develop a ARIMA(p,q,r) model in Matlab. Thanx a lot Vamsi help armax (system identification toolbox) /Johan Bala Vamsi Tatavarthy wrote: > Hi, > (Sorry for cross-posting) > I am clueless w.r.t using matlab for time series. I have a time series > and I would like to make estimates of future using the past. How do I > develop a ARIMA(p,q,r) model in Matlab. > > Thanx a lot > > Vamsi > ...

opengl picking, selection buffer problems
hi, i am trying to pick a 3d vertex. i have an opengl canvas in vb.net which gives 3d x,y,z values using gluUnproject, which by taking mouse 2d x,y and passing to gluUnproject and getting 3d x,y,z. but now the problem is in picking...i am sure i am right but need some opinions, 0n my gluPickMatrix: -my x & y should be 3d x & y (result of gluUnproject & and i dont need to minus it from the viewport(3)) -my viewport(2&3) need to be converted to 3d x,y as current they are in windows x,y dispite doing all this i still get errors in my selction buffer ie it does not give the co...

compile problems: fp_class.h
Hello, I've got a little old source-package that i try to compile. Compiler tells me that it can't find fp_class.h and consequently `FP_POS_NORM' is undeclared. From what I've found on google i conclude that fp_class.h is just not available on linux. How can I port this to linux then? Are there any surrogates for this fp_class.h? And what is this include file ment to be anyway? Thanks for all the input, Stephan ...

Cannot open *.fig files from MATLAB 2008b in MATLAB 2014a
Like in subject, I cannot open figures made in MATLAB 2008b in MATLAB 2014a environment. Scenario: copy *.fig files from 2008b environment into 2014a, set paths with subfolders, try to open *.fig in 2014a. I would like to have a confirmation if it is compatibility problem or not. Here is the answer form MATLAB in Command Window java.lang.ClassCastException: [D cannot be cast to [Ljava.lang.String; at com.mathworks.toolbox.matlab.guide.LayoutEditor.completed(LayoutEditor.java:2217) at com.mathworks.toolbox.matlab.guide.LayoutEditor\$ReadFigureCompleted.completed(LayoutEditor.java...

Desktop resolution problems with ATI Radeon 9800 Pro #2
I hope that someone will be able to explain the following problem that I am having: I bought a Dell XPS 3.0 Ghz, 1GB RAM, ATI Radeon Pro 128MB. I am using it with my Dell 19" Triniton monitor, PF991 or so I think. I started it up, and the desktop resolution that made most sense was the one between 1024x768 and 1280x1024. Something like 11??x???... I am at work now and cannot look at it. In any case, I also tried 1280x1024, changed the default refresh rate from 60 to 75 and it was fine, but just too small for my taste. During the next three hours, as I was just downloading inoffensiv...

How to create a DLL for LabVIEW in MatLab
I want to use MatLab-Code from an M-file in LabView without MatLab. So i decide to use external code in a DLL. Can anybody give me some hints - how to do? (How to create, how to use?) Used System Windows 98, LabVIEW 6.1, MatLab 6.1 R12.1 Thanks Hi, I use Matlab-Code in Labview and it's don't need create a dll. The LV was a tool, matlab script, you can write your code Matlab here. see the examples of LV.I think the lV 6.1 have. Dll it's very complicated :D I would like to use LabVIEW !without MatLab. If i use these solution i need MatLab too. I've investigated and i think ...

MATLAB mistaken a structure with a figure
I have some *data* structure S that I save in matfile save xxx.mat -struct s With V 2014B I get the warning message Warning: Figure is saved in D:\Documents\MATLAB\XXX.mat. Loading this file recreates and displays the figure and its contents. Refer to save for more information. K>> [~, b] = lastwarn b = MATLAB:Figure:FigureSavedToMATFile It looks like MATLAB mistaken my data with a figure. This works fine under 2014A and previous. Annoying. Some how I feel I will have a lot of works to do to adapt my codes for the new release 2014B. Bruno ...

Streamlines in Matlab
Hi guys, I am very new to matlab, so any help at all would be very much appreciated. I am attempting to plot the streamlines for a streamfunction with contour lines: C (=constant) = y/3 - 3y/ [(x- 3/2)^2 + y^2] Would anybody be able to help me with this? Thank you very much for your time. On Feb 21, 3:59=A0am, ben <bl...@ic.ac.uk> wrote: > Hi guys, > > I am very new to matlab, so any help at all would be very much appreciate= d. I am attempting to plot the streamlines for a streamfunction with contou= r lines: > > C (=3Dconstant) =3D =A0y/3 - =A03y/ [(x- 3/2)^2 =...

problem in Konsole
Hi How can I reinstallate the Konsole? And what is the name of rpm package of Konsole. This is becasue after I reconfig the display card driver, the Konsole is out of order. Please advice, Thx, Nicholas �j�O wrote: > Hi > > How can I reinstallate the Konsole? > > And what is the name of rpm package of Konsole. > > This is becasue after I reconfig the display card driver, the Konsole is out > of order. > > > Please advice, > > > > Thx, > > > Nicholas > > Konsole comes with kdebase: rpm -qf `which konsol...

Problems with update-ux
I am using update-ux. After the firs CD I have the following error. Any idea? ERROR: The second CD does not contain the expected contents. Please make sure you have inserted the correct CD. If you have inserted the correct CD you can continue. Do you want to continue ? (y/n)y Please insert the second CD and then press any key to continue. ERROR: The second CD does not contain the expected contents. Please make sure you have inserted the correct CD. If you have inserted the correct CD you can continue. Do you want to continue ? (y/n)y Please insert...

Newshound problem
Hi I have just transferred my mail setup to an A9Home( I copied everything over ShareFS). I use MP4.08, Hermes 1.13 and NewsHound 1.43pre3(5-Aug-03). As long as I don't run NH there are no problems. Once NH is run I get the following warning from NH 015 Warning : DNS Resolve failed - domain server unreachable? I can carry on fetching mail without problems but NH throws the same warning and my browsers also cannot resolve host (Domain name not found).This continues until I reboot the machine. My router acts as my DNServer and, as I can still browse on my other m/c, I...

Hi, I have a task T_Check that checks if a number is a prime one. I have a task T_Manager that manages the checks. In T_Manager I have an array of T_Check(1..N). Now, lets say I want the T_Manager task to check the numbers 1..100 if they are prime. I have only 8 T_Checks tasks (N=6). How do I manage the tasks allocations ? I thought about T_Manager getting a notification from T_Check when it finishes checking, and when T_Manager is notified it shold recall the Check entry in the T_CHeck task that notified it. The problem is that I dont know how to know which task (T_Check) amongst the Nth tas...

20 New MATLAB and Simulink based books #2

Obtain error message from MATLAB engine
Hi, I use the MATLAB engine to control MATLAB from a custom C program. Everything works fine, I can open the engine and send commands via engEvalString(). However, I would like to how to retrieve the error message from MATLAB if the sent command caused an error. I managed to obtain the output of valid commands through engOutputBuffer(), but it appears that error messages are _not_ placed in the output buffer. But surely it must be somehow possible to come by them? Hi John, How about using engEvalString() to execute the lasterror MATLAB function? That's all I can see. I used the COM ser...

Problem with Modelsim 6.5 and Matlab/Simulink 2012a version
Sir, I'm using Matlab 2012a (32 bit) in my Windows 7 (64 bit) os and Altera web edition 9.1 (32bit)and Modelsim 6.5b (bit). When I tried to RUN MATLAB EXAMPLE: Verifying Viterbi Decoder Using ModelSim or Creating an FPGA Domain Model (dxpcSGIO301servo_fpga ) I got Warning: ModelSim Altera edition is not supported by HDL Verifier > In hdlsim>l_ParseVsimVersion at 1068 In hdlsim>l_GetModelSimLibInfo at 527 In hdlsim at 115 In vsim at 106 AND: at Modelsim: # ** Error: (vsim-FLI-3155) The FLI is not enabled in this version of ModelSim. # ** Error: (vsim-F...

Setting up SNMP with iPlanet (newbie problems!)
Hi, I am trying to set up SNMP on iPlanet Web Server (version 4.1 - I know it's very old) on Solaris and I can't get any webserver statistics on my network manager box. However, I can get some 'basic' SNMP stats such as 'sysDescr - 1.3.6.1.2.1.1.1' and 'snmpInPkts - 1.3.6.1.2.1.11.1'. I start each agent as follows: master agent: ./magt CONFIG INIT& subagent: using the admin server's web interface. My config file is extremely simple and only sets the 'public' COMMUNITY. Does anyone have any ideas how I can get the webserver stat...

Problem with C++ program while using CC-compiler
Hi, I have a problem with C++ program below while using CC-compiler. \$ CC -V CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 ------ C++ Program (foo.cpp) ------ #include <string> #include <vector> using namespace std; int main () { char* a[] = {"AAA", "BBB", "CCC"}; vector<string> v (&a[0], &a[0] + sizeof(a)/sizeof(*a)); // Line#8 return 0; } ------------------------------- Compilation: \$ CC foo.cpp "foo.cpp", line 8: Error: Could not find a match for std::vector<std::string>::vector(char**,...

matlab pool
may i knw what is batch job, matlab pool in parallel computing I am sorry, but I think you need to be a bit more specific in your question. Did you look in the documentation before you asked this question? --DA "Daniel Armyr" <firstname@lastname.se> wrote in message <ghj5it\$g1n\$1@fred.mathworks.com>... > I am sorry, but I think you need to be a bit more specific in your question. Did you look in the documentation before you asked this question? > > --DA In R2006b , there havn't give any information regarding matlab pool or batchjob in the documentatio...

Xilinx Swift interface Licence (?) problem
I all. I finally succeded (or at list I think I did!) in setting up the swift libraries to simulate my design with a PPC in it (Xilinx EDK6.2), but when I run the simulation with ModelSim XE I got this "strange" message: # ** Error: Failure to license for PE Swift Interface. # ** Error: Unable to check out PE Swift license. WHY PE edition if I have a XE edition, I did everything required (see http://www.xilinx.com/xlnx/xil_ans_display.jsp?getPagePath=14019 ) and I compiled the Xilinx libraries in ModelSim with the following command line??? compxlib -s mti_se -f virtex2p:m -l vhdl...

HP Print Problems
Hi, Can someone please tell me what might be wrong with my printer? I have a HP LaserJet 1200 and I am now getting a smudge line one inch in from the left hand side on about 1 in 7 sheets. It goes all the way down the page and in fact most pages now are printed with black marks in that area of the page. I have changed the Toner but that makes now difference. Cheers in advance, Lenny Lenny If changing the toner didn't fix it then the likely cause is a failing fuser. Could be a buildup of toner on the fuser roller or it could be that the fuser his coming to the end o...

General Java Matlab lib questions
Am somewhat of a Matlab noob and I have some general questions, maybe someone could comment: - Can I write a Java app that could take as input the following: - Data from an external source (say a database) that represents Matlab variables (like matrices) - A string that represents a Matlab expression that is a function of these variables And then produce the output of the expression, in the form of a matrix or a scalar. In other words, is it possible to parse a string that represents a Matlab expression and execute the expression in the Matlab environment from Java? ...

problem to insert data
hi i have an insertion problem with my rtu table datatype for date1 field is: datetime i try to insert local date to the database (mysql) source code struct tm *date; struct timeval begin; struct timeval end; gettimeofday(&end, NULL); date = localtime(&end.tv_sec); strftime(datestr, 128, "%F %T", date); printf("date str %s", datestr); snprintf(query, 512, "INSERT INTO rtu (date1,duration,sensorid) VALUES(%s,%d,%d)",datestr, 0, 0); res=mysql_query(&my_connection,query); res display 1 (a error) datestr display me 2004-11-25 15:52:55 query varia...