COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

### Matlab Problem with Ideal Gas Law

• 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

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

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

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 205332 articles. 554 followers.

4 Replies
380 Views

Similar Articles

[PageSpeed] 7

• Email
• Follow

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...

problems problems problems
(The short(?) summary) I've got an Access MDB file and a DAO connect with it.. Problem 1 of 2 The below gives me a runtime error 91 Object variable or With block variable not set. I've got the db stuff after the form.show (to make sure all the objects on the form are loaded before attempting to utilize/manipulate them) But it doesn't like it when I use the data object in the form load anyway for some reason.. pffft. Private Sub Form_Load() frmTest1Project.Show datGallery.Recordset.MoveLast datGallery.Recordset.MoveFirst Call LockTextBoxes(frmTest...

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 with matlab
I have to find the period of a certain periodic waveform that is make up of data points of a matrix Y. This matrix has a total of 27881 rows and 7 columns. The 2nd column and the 4th column is the y axis data points and time data points respectively. The method i did was to do a loop to get the index that represents the max peak value. The problem is that i am umsure how to start another loop counter from the last index value that is achieved from the looping that i have used earllier. Here is the codes. Coz to get the period i decide to use the peak to peak approach Another way is how t...

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...

Problems problems....
I've got Fujitsu MAN3184MP and Adaptec 29160 scsi card. Sometimes i have this message "A disk read error occured" , sometimes even bios does not recognize it, sometimes it does but the boot sequence does not start it seems that motherboard bios has problems with it ( so it seems to me, i could be wrong about that assumption) . Then i reset and it all works perfectly. I've noticed a speed degradation in Win XP lately. I'm angry :)) I have LVD/SE terminator, and i think 68pin cable ( not sure about that ). Hope i gave you enough info to try and help. Thanx! -- -...

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

Problem with a problem
Hello, take a grammar G with alphabet {0,1} such that (the word problem for) the language L_G={w in (0+1)*|w\in L(G)} is very complex, say in PSPACE or some higher complexity class. Now consider an "easy" problem EASY like: "Is an element of L_G in L_G?". Well, this seems to be fairly easy because the answer is "yes" in any case. Hence the problem should be of small complexity. But if one models such a decision problem one has to construct a language L with alphabet A such that the word problem for L reflects exactly the decision problem which one is interested...

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...