Home > Archive > Matlab > April 2005 > matlab plotting help
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
matlab plotting help
|
|
| Jeremy Turner 2005-04-28, 4:06 am |
| 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
| |
| Chris Hulbert 2005-04-28, 4:06 am |
| 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
| |
| Jeremy Turner 2005-04-28, 4:06 am |
| 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:[color=darkred]
>
>
> 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[color=darkred]
I'm[color=darkred]
> code:
> on
|
|
|
|
|