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 208730 articles. 9 followers. lunamoonmoon (258) is leader. Post Follow

4 Replies
529 Views

Similar Articles

[PageSpeed] 22

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
Reply:

Similar Artilces:

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

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

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

Run Matlab ... from Matlab
Hello, Is there any limitation to run Matlab from Matlab, as a system command, on Linux platforms ? I tried to start Matlab, both using the ! syntax (!matlab&) or the system command (system('matlab&')), the Matlab splash screen appears, but the new Matlab session closes rapidly . When I do the same with a script of mine (system('matlab -r "myscript"&')), my script is being executed, but Matlab finally crashes . If I remove the &, it works well, but the first Matlab session is blocked till I close the second one . I run Matlab on a Linux 64bits pla...

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

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

MATLAB talking to MATLAB?
For my project, I need to have a client program (MATLAB executable) talking to a server program (also MATLAB executable) to query data. Is there any easy way to accomplish that? I appreciate any help that I can get on that. Thanks. Cheers, Hoi Oops, I forgot to mention. There are multiple clients querying the server, so I guess serial objects + remote serial port wouldn't work. "Hoi Wong" <wonghoi.ee@gmail.com_> wrote in message news:f3ald6$gg4$1@news.Stanford.EDU... > For my project, I need to have a client program (MATLAB executable) > talking to a ser...

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

problem opening Matlab figures created by MATLAB installed at the other PC
Hi there, I have a Matlab Version 7.0.0.19920(R14). when opening a figure created at the other PC (Also MATLAB 7) > open('Fig5PRL.fig'); one gets the message ??? Error using ==> open Unable to find function containerDelete within C:\MATLAB7\toolbox\matlab\uitools\javacomponent.m Meanwhile, the figure can be successfully opened at the computer where it was created and at the other with MATLAB 7 installed. Any ideas how to treat this? Yours, Petr. ...

problems with code to convert ncs file in matlab under Matlab R14(2004)
Hello to everyone, Ill try to run Nlx2MatCSC ( a code from neuralynx than convert continuous file to matlab variables) in Matlab R14 (2004), and it doesn't work: When I type: >> [Timestamp, ChanNum, SampleFrequency, NumValSamples, Samples] = Nlx2MatCSC(Filename, [1 1 1 1 1], 0, 3, [0 4 9]); ??? Attempt to execute SCRIPT Nlx2MatCSC as a function. I heard that this code is running in Matlab 2007a and newer, but...what about this old version? Any help, Cheers ...

Display problem in Matlab Figure windows on mac running matlab remotely
I am running matlab remotely using x11 and I am having trouble with the display in figure windows, such as with use of plot() command. The figure will appear with the correct information, but the color mapping seems to be off, and most often the window appears with a mix of purple and green colors instead of black and white. I am running a mac (10.4.11) where I connect remotely using x11 to a linux server where matlab 2007a is installed. I would appreciate any assistance. ...

Problems with Matlab 6.5.1 R13 to Matlab 7 R14
I've written a GUI, with text in it. When I open it with Matlab 6.5.1 R13 there are no problems to show the full text for Matlab. But when I try it with Matlab 7 R14 the text is shown incomplete. This is because Matlab 7 prints the font bigger than Matlab 6.5.1... Is there a font, which is in the same size in Matlab 7 R14 AND Matlab 6.5.1 R13? Thanks ...

some problems of codes of MATLAB 7.0 working on MATLAB 6.5
I have used MATLAB for few hours.So I don't know the differences between version 6.5 and 7.0.I want to use some codes of MATLAB 7.0, but they doesn't work in MATLAB 6.5.How to change these codes so that they can work in matlab 6.5.Waiting for your help. Thank you . The codes are like this .I think changing the function findPI may work ,but I don'y know how % PIfun.m % Evaluate a function used to find the PI-line, using Kyle Champley's % method. % % Adam Wunderlich % last update: 5/18/06 function y = PIfun(r,R,h,gamma,x3,sb) temp = R - r*cos(gamma-sb); y = h*((pi - 2*atan(...

Web resources about - Matlab Problem with Ideal Gas Law - comp.soft-sys.matlab

Problem novel - Wikipedia, the free encyclopedia
Working class, or proletarian novels are often also social problem novels . This was in many ways a reaction to rapid industrialization , and ...

LG admits G4 bootloop problem is a hardware fault, will repair affected devices
... a hardware defect and will repair affected devices. According to the numerous posts on various social platforms and YouTube, the bootloop problem ...

Problem
"The governments in Paris, London and Brussels have completely lost control, they are not able to maintain the rule of law and they are miserably ...

Russia says a growing problem in space could be enough to spark a war
... space junk grows so large that a single collision could set off a domino effect of increasingly more collisions. For Kessler, this is a problem ...

The problem with Trump's make-it-in-the-USA push
His calls for bringing factory jobs back and slapping stiff tariffs on foreign-made goods would cost Americans plenty

Cleveland police problem started at the top: Phillip Morris
cleveland.com Cleveland police problem started at the top: Phillip Morris cleveland.com In this file image, a prosecutor points out locations ...

Retail's Amazon.com problem
Amid Amazon's extended love affair with Wall Street, the rest of retail is getting hammered.

Hannity Teams Up With Rumsfeld To Blame Obama For Problems In Iraq
Of all people who should have no credibility on the subject of the Iraq war, it’s “We know where the WMDs in Iraq are” and “I doubt the war will ...

O’Malley Points Out Animals Don’t Have Employment Problems
'We're the only species on the planet without full employment'

Small town of Sebring, Ohio, also facing lead drinking water problems
Located four hours to the southeast of Flint, Michigan, there’s another town facing a potential lead crisis in its drinking water. Sebring, Ohio, ...

Resources last updated: 1/28/2016 3:46:00 PM