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 201246 articles. 513 followers. Post

4 Replies
201 Views

Similar Articles

[PageSpeed] 27

  • 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); -----------...