I have a code, and I was figuring out the equations to plug into my for loops, testing as I went. The initial run throughs were fine, yielding results that weren't quite correct, but were expected. Now, while I think I have my final equations, the variable that I would like to see is getting repeating values, and I do not know why.
In my code V3 should equal A2 times V2 times 1.1, all divided by A3. A3 is constant, but A2 and V2 change with every loop iteration. However V3 is getting repeating resutls.
Code Below
Thank You
clc;clear all;close all;%Define variables
d1 = .05; %m
A1 = (pi/4)*d1^2;%m^2
d3 = .01; %mA3 = (pi/4)*d3^2;%m^2d2 = (0.1:.1:0.5).*d1;%mA2 = (pi/4)*d2.^2;%m^2L = 0.5; %mh = 3; %mrho = 1000; %kg/m^3
Pt = [500 750 1000].*1000; %Pa gauge
g = 9.81; %m/s^2
%Preallocation Matrices
Vave = zeros();%m/s
Ptube = zeros();%Pa
V3 = zeros();%m/sV1 = zeros();%m/sV2 = zeros();%m/s%Loop to iterativly calculate Vave, Ptube, V2, and V3
for j = 1: length(Pt) for k = 1:length(d2) Vave(j,k) = sqrt((Pt(j)*A1 +rho*g*h*A1)/((((rho*A1)/2)+... ((0.002*rho)/2)*(2*pi*(d1/2)*L)+2*pi*(d1/2)^2))); Ptube(j,k) = Pt(j) + rho*g*h-(rho*0.002*Vave(j,k).^2)/2; V2(j,k) = (A1*Vave(j,k))./(A2(k)*(.1+1)); V3(j,k) = (A2(k).*V2(j,k)*(1.1))/A3; endendplot(V3, d2);xlabel('Nozzle Velocity (m/s)');ylabel('Pump Jet Nozzle diameter (m)');legend('Pt = 500kPa', 'Pt = 750kPa', 'Pt = 1000kPa', 'location', 'southeast');
Best Answer