Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

matlab plotting help
I realize this is probably a basic question to be asking on this
forum, but i'm writing a program for a class to plot the mass
specific thrust versus the compressor ratio of a jet engine. I'm
having trouble actually getting the thing to work. here is my code:

cp = 1.004;
pamb = 18.75;
t1 = 216.7;
qf = 45000;
effcomp = .85;
effturb = .90;
k = 1.4;
r = 287.05;
c1 = (k*r*t1)^(1/2);
m = .85;
v1 = c1 * m;
t2 = t1 + (251.05^2)/(cp*2000);
p2 = pamb/((t1/t2)^(k/(k-1)));
for tmax = 1500
for compratio = 2:100
p3 = compratio * p2;
t3s = t2*(compratio)^((k-1)/k);
t3 = ((t3s - t2)/effcomp) + t2;
p4 = p3;
f = ((tmax/t3) - 1)/((qf/(cp*t3))-(tmax/t3));
t5s = -t3 + t2 + tmax;
t5 = -effturb*(tmax - t5s) + tmax;
p5 = p4/((tmax/t5)^(k/(k-1)));
t6 = t5/((p5/pamb)^((k-1)/k));
v6 = (2 * 1000 * cp * (t5 - t6))^(1/2);
mspthrust = ((1 + f)*v6 - v1);
tsfc = f / mspthrust;
plot(compratio, ((1+f)*v6 - v1))
fprintf (1, 'tmax = %.2f mspthrust = %.2f, tsfc = %.10f\n',
tmax, mspthrust, tsfc);
end
end

i would so so so so much appreciate any help anyone can give me on
what is wrong with my plot function.

thanks

Report this thread to moderator Post Follow-up to this message
Old Post
Jeremy Turner
04-28-05 09:06 AM


Re: matlab plotting help
You keep plotting a single point for one. First vectorize your code.
You can eliminate both loops. Look at the element-wise operations
.*, ./, etc. Then plot it as a vector.
Jeremy Turner wrote:
>
>
> I realize this is probably a basic question to be asking on this
> forum, but i'm writing a program for a class to plot the mass
> specific thrust versus the compressor ratio of a jet engine. I'm
> having trouble actually getting the thing to work. here is my code:
>
> cp = 1.004;
> pamb = 18.75;
> t1 = 216.7;
> qf = 45000;
> effcomp = .85;
> effturb = .90;
> k = 1.4;
> r = 287.05;
> c1 = (k*r*t1)^(1/2);
> m = .85;
> v1 = c1 * m;
> t2 = t1 + (251.05^2)/(cp*2000);
> p2 = pamb/((t1/t2)^(k/(k-1)));
> for tmax = 1500
> for compratio = 2:100
> p3 = compratio * p2;
> t3s = t2*(compratio)^((k-1)/k);
> t3 = ((t3s - t2)/effcomp) + t2;
> p4 = p3;
> f = ((tmax/t3) - 1)/((qf/(cp*t3))-(tmax/t3));
> t5s = -t3 + t2 + tmax;
> t5 = -effturb*(tmax - t5s) + tmax;
> p5 = p4/((tmax/t5)^(k/(k-1)));
> t6 = t5/((p5/pamb)^((k-1)/k));
> v6 = (2 * 1000 * cp * (t5 - t6))^(1/2);
> mspthrust = ((1 + f)*v6 - v1);
> tsfc = f / mspthrust;
> plot(compratio, ((1+f)*v6 - v1))
> fprintf (1, 'tmax = %.2f mspthrust = %.2f, tsfc = %.10f\n',
> tmax, mspthrust, tsfc);
> end
> end
>
> i would so so so so much appreciate any help anyone can give me on
> what is wrong with my plot function.
>
> thanks

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Hulbert
04-28-05 09:06 AM


Re: matlab plotting help
yeeah. i took a summer course in computer science, and am not exactly
sure what "vectorizing" my code means. I do have a little experience
with matrices in mathematica, but i wouldn't know where to begin on
this. Is this the only way to correct the problem? if it is, does
anyone know any help site that I can be directed toward to understand
this "vectorization" of my code?

thanks

Chris Hulbert wrote:
>
>
> You keep plotting a single point for one. First vectorize your
> code.
> You can eliminate both loops. Look at the element-wise operations
> .*, ./, etc. Then plot it as a vector.
> Jeremy Turner wrote: 
this 
I'm 
> code: 
> on 

Report this thread to moderator Post Follow-up to this message
Old Post
Jeremy Turner
04-28-05 09:06 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Matlab archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:15 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.