Matlab Problem with Ideal Gas Law

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply lildevil111269 (3) 1/27/2010 3:32:10 AM

See related articles to this posting


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
Reply lildevil111269 (3) 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
Reply none1568 (7455) 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
Reply lildevil111269 (3) 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
Reply none1568 (7455) 1/27/2010 5:16:34 AM
comp.soft-sys.matlab 203370 articles. 529 followers. Post

4 Replies
266 Views

Similar Articles

[PageSpeed] 30


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Need help with the ideal gas law.
Ladies and or Gentlemen, I have a CO2 Gas Concentration expression: [CO2 concentration] = (-(ln (1 . (1 . Ratio/zero)/span)) / a) ^ (1/b) Where Ratio is the ratio of active to reference peak to peak signals and is essentially independent of variations in source intensity over time. This ratio reduces in the presence of target gas. It is the reduction in this ratio that is used to determine the target gas concentration. The reduction in ratio is non-linear. Where zero is the ratio in the absence of target gas. Where span is determined during calibration and a = 0.0005989...

Problem in solving a problem by matlab.
Hello Everybody, I am having a problem in back propagation network. It is not a direct one to use sofwares like matlab for simulation. The problem is briefly described as follows. I want to specify the number of interconnections in the hidden layer or between the hidden layers. Can this possible using Matlab? Also I want to share the weights between two sets of hidden layers how to do that in Matlab? Please suggest me any other GUI softwares that can solve both the above problems or give me suggestions or atleast the posibility of doing this in Matlab(any...

Matlab 7
I have Matlab 7.0, including Matlab Web server (ver 1.2.3). I have a problem using it. My computer is XP Prof (SP2), Pentium 1GHz. This problem does not occur with Matlab 6.5. The Matlab server is executed from a Web page and it launches Matlab 7 functions. The Matlab functions compute results and display these (using Matlab server) on other Web pages. The problem and observations are: 1. After the server-launched Matlab finishes its work, if I open a new Matlab 7, this runs very slowly because it uses up more than 80% of computer CPU (and about 60MB memory). 2. The launched Matlab, even af...

technical problem with matlab 7R14sp1 start matlab
Its for a problem when i start matlab there is an error message and i can t use matlab --------------------------------------------------------- the message is: microsoft visual c++ runtime library runtime error! program:c\Apllications\matlab7\bin\win32 \matlab.exe this application has requested the runtime to terminate it in an unusual way. Please contact the application's support team for more information ------------------------------------------------------- It is very annoying because i work very much with matlab. ...

problems when changing from matlab R2007a to matlab R2008b
Hi all, I have problems when changing from matlab R2007a to matlab R2008b. I have a simulink model running in R2007a which i use to obtain certain results. Nevertheless, these results are differents when i try to run the same simulink model in R2008b. I have done nothing different but running the same model in the new matlab version. I don?t know if i have to change some configuration parameter connected to the new matlab version. If someone could help i would appreciate it. Thank you Dami?n Palenzuela ...

Problems calling from Matlab a Matlab compiled dll
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\inclu...

Problems calling from Matlab a Matlab compiled dll #3
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\inclu...

Problems calling from Matlab a Matlab compiled dll #2
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\inclu...

problem saving plot as jpeg and problem with matlab webserver
Hi, I have made an application that plots a figure. I am trying to use matlab webserver to send the data to an html file. The problem is that I want to save the plot as a jpeg file. I used the following code taken from various examples. --------------------------------------- wscleanup('*test.jpeg', 1); f = figure('visible','on'); ....plotting.... drawnow; s.GraphFileName = sprintf('%test.jpeg',mlid); status = wsprintjpeg(f, s.GraphFileName); (or wsprintjpeg(f, s.GraphFileName); instead) s.GraphFileName = sprintf('/icons/%test.jpeg',mlid); -----------...

Matlab problem!!
Dear All I hope that you are doing well and everything is OK. I have a question, please: I have a decimal number stored in a matrix. For example, Matrix subscripts: 1 2 3 5 6 7 8 9 10 Values: 8 9 8 7 7 9 9 2 7 So, the number is: 898779927 My matrix consists of 3000 cells and each cell contains a number from 0-9. I need to get the number of bits for this string in binary. However, I cannot convert it to binary as the program will give me out of range. Thanks and your response will be much appreciated. Sincerely, Kal...

PROBLEM IN MATLAB!
This is a multi-part message in MIME format. --------------020208050403030404070307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I am facing a strange problem with MATLAB. I have a function prolate_legendre_expansion.m which behaves as follows. If called at the MATLAB prompt, for example as >> [beta] = prolate_legendre_expansion (1,30) it works fine. However, if this function is called from within another test function (called test_prolate.m, which does nothing else except call the function above) as >> test_prolate it ...

Why did Matlab have problem on this ?
I have ML 7 .1 and it has problem on my computer on this equation (no error, just takes all the cpu power and I have to manually end the task ) syms x ; log((exp((exp(9)/cos(((cos(exp(sin(7-log(x)*(6))))))))))) Do you want the CPU on our computers to be consumed as well ... ? Try each of the parts in your expression separately until you find the root of the problem :) tvn wrote: > I have ML 7 .1 and it has problem on my computer on this equation (no > error, just takes all the cpu power and I have to manually end the task > ) > > > > syms x ; log((exp((exp(9)/co...

A problem with matlab
Hi, folks: I have a problem with the running of a matlab software under Windows 2000. The problem is that when I double-click the matlab executable short-cut on the desktop, the software first searches the documentation disk on the default CD-ROM, but I donot have the documentation disk in my hands. As a result, although I have a well-installed matlab in my computer, I can't run and use it successfully. So I appreciate that someone email me the detailed solution so that I can run matlab without the documentation disk. Thanks, James "James" <gyu@ece.ualberta.ca> wrote in...

Problem using Matlab 6.5 codes in Matlab 2007b
I have written some code in Matlab 6.5 and they are running perfectly in that version. But if I try to run the same using Matlab 2007b, I am facing problem. It starts giving error like dimensional mismatch and etc. Why the program written in lower version is not running in higher version? "Dwaipayan Dasgupta" <ddg.abhhih@rediffmail.com> wrote in message <gvto39$jsf$1@fred.mathworks.com>... > I have written some code in Matlab 6.5 and they are running perfectly in that version. But if I try to run the same using Matlab 2007b, I am facing problem. It starts giving error...

I have a problem with matlab
I'm universitary student, I need to risolve an exercice with matlab 5.0 student: bisection of function exp(x)-2 in [0,1] Please help me. Thanks in advenced. easy wrote: > I'm universitary student, I need to risolve an exercice with matlab > 5.0 student: > bisection of function exp(x)-2 in [0,1] > Please help me. > Thanks in advenced. If you post the code that you've started with and explain exactly where you're getting stuck, we may be able to help you. We don't want to rewrite the code that you've already written, after all. -- Steve Lord slord...

Matlab Problems
Hi all, I encounter some Matlab problems. I have 4 figures. How do I find the mean of the 4 graphs at their specific frequencies? I write h=tf(1:43001), then [num,den]=tfdata(h), and then fvtool(num,den); to design a filter. What is wrong with my sentence? How do I derive an accurate frequency response for a potential transformer? Thank you. ...

My Matlab Problems
My code needs to take the coordinates of three points, A, B and C and the heading of an aircraft at point C and calculate the distance between B and C and the direction of B viewed from the aircraft at C. 1. Function 1: Given the (x,y) coordinates of three points A, B and C calculate the polar coordinates of the vectors from A to B (Ob, Rb) and from A to C (Oc, Rc). Imagine that you have made a triangle out of the 3 points A,B and C. Return the distance between B and C , the angle O between the lines from A to B and from A to C, as well as the angle O3 between the sides from C to B...

More Matlab Problems
I have worked on that Matlab program that you all helped me with (thank you so much), but I've only written the first three functions and I need some help on the rest of them. If you can help thank you. Function 1 function[d,O3,Oc] = fun1(xa,ya,xb,yb,xc,yc) % FUN1 finds the distance(b&c) and two angles % function[d,O3,Oc] = fun1(xa,ya,xb,yb,xc,yc) % d=distance between b & c % r1=distance between a & b % r2=distance between c & a % Oc=angle between the lines from a to b and from a to c % O3=angle between sides from c to b and from c to a d=sqrt((xb-xc).^2 + (...

Problems with Matlab
I am running Matlab R12 on a server. I ran into problems with connecting to the server, does anyone knows what the message means? Warning: Cannot load class com/mathworks/jmi/OpaqueJavaInterface. MATLAB Java services cannot be initialized. Thanks Install Java platform and try again <http://java.sun.com/j2se/> Francis Lee wrote: > > > I am running Matlab R12 on a server. I ran into problems with > connecting to the server, does anyone knows what the message means? > > > Warning: Cannot load class com/mathworks/jmi/OpaqueJavaInterface. > MATLAB Java services c...

Problem Matlab
After installation of MATLAB 7.0 R14 to throw of schedule I have The following mistake: Error occurred during initialization of VM Could not reserve enough space for object heap Stack Trace: [0] jmi.dll:_mwJavaAbort@0(0, 0x473b5ea8, 0x7816ff14, 0x00cde804 "D��") + 21bytes Fatal Java Exception detected at Wed Jul 27 08:01:42 2005 I can anyone it know pointing to me what do to solve problem? Thank you. Please email support. Stuart "Domanda" <titurbina@tiscalinet.it> wrote i...

problem in matlab
Hello everybody . I have MAT LAB 2009 version software but it doesn't work properly in my system because in my system the RAM is 512 MB . when i started MAT LAB it takes lot of time in processing . Please any one provide me Mat lab software which is compatible to my system. On 1/4/2012 11:41 PM, siddhartha chandel wrote: > Hello everybody . I have MAT LAB 2009 version software but it doesn't work properly in my system >because in my system the RAM is 512 MB . when i started MAT LAB it >takes lot of time in processing . Please any one provide me Mat lab software which is comp...

a problem in matlab
Hi I have a lot of files with ".ls1" as extention. I must read them in Matlab but they are not recognizable For Matlab! Ls1 files could be imported in excel software and be saved as ..xls or .xlsx files. Since number of .ls1 files are about 100 so i cannot save them as .xls file one after another one because there are a lot of such fills. i should do it by the use of a simple way. * it should be noted when i save as a .ls1 file as a .xls file a message appear and i must click on "yes" so i cannot change their extention using windows extention control. Please guide ...

Matlab Problem!!!
I'm trying to run the program: function [x,numIts]=newton(f,x) EPSILON = 1.0e-6; MAXITS = 500; for numIts=1:MAXITS [y,yprime] = feval(f,x); increment = y\yprime; x = x - increment; if norm(increment)<EPSILON break; end end But cannot seem to get it to run. What commands do I need to enter to get this thing to run?!?!?! Thank you for the help Matt wrote: > I'm trying to run the program: > function [x,numIts]=newton(f,x) [etc] > But cannot seem to get it to run. What commands do I need > to enter to get this thing to run?!?!?! What, more precisely...

Problem with MATLAB
Hi All: I am having a problem with the software MATLAB and was wondering if anybody out there on the L could help. Thanks and regards Kumar ********************************************************************* This message and any attachments are solely for the intended recipient. If you are not the intended recipient, disclosure, copying, use or distribution of the information=20 included in this message is prohibited -- Please=20 immediately and permanently delete. On Sep 26, 12:04 pm, nagakumar.srid...@SPCORP.COM ("Sridhar, Nagakumar") wrote: > Hi All: > ...