Filter löschen
Filter löschen

How to put the value of guess into equation

3 Ansichten (letzte 30 Tage)
Danish Iqhwan Rohaizad
Danish Iqhwan Rohaizad am 25 Jan. 2022
Hello everyone, I am trying to put the value of my M1 (which is a guess) into the equations after the loop. However Matlab does not detect the M1 (guess) as it is supposed to. Instead, it stated there that the variable 'rho' was unrecognized. Currently stuck in this coding and need help on how to progress. Thank you !
%% 0 = Total state/conditions
%% 1 = inlet to the volute
%% 2 = inlet to the rotor
%% 3 = exit to the rotor (upstream)
%% 4 = exit to the rotor (downstream)
%% Calculation
%Station 1
R = 287; %Gas constant
T01= 339; %Stagnation Temperature or total inlet temperature
Patm = 101325;
p01 = 124638.717; %Total Inlet Pressure
A1 = 0.0025686; %Area inlet volute
Cp = 1004; %Constant pressure
Cv = 717; %Constant Volume
kc = Cp/Cv; %specific heat ratio
kc0 = (kc-1)/2; %specific heat ratio at total state
kc1 = 1/(kc-1); %specific heat ratio at inlet volute
kc2 = (kc1*kc); %specific heat ratio at inlet rotor
M1 = 0.178
%% if Mach number <0.3, considers as incompressible fluid as the density remains the same
%% if Mach number > 0.3, fluid considers as compressible with the changing value of density
%% Supersonic flow, M > 1 (choking occurs @ nozzle )
%% Guess for Mach Number, M1
answer = randi(2.0);
answer = 0.178;
%store the numer of guesses made
numGuesses = 0;
%%Repeatedly make guesses
guess = -1;
while (guess ~= answer)
%increment the number of guesses
numGuesses = numGuesses + 1;
%% Random number for M1 to guess
guess = input('Guess a number between 0.1 and 2.0: ');
%% Tell user if guess was correct or not
if guess < answer
fprintf('Your guess (%i) was too low!\n', guess);
elseif guess > answer
fprintf('Your guess (%i) was too high!\n', guess);
else
fprintf('Your guess is correct (%i)!\n', answer);
fprintf('It took you %i guesses to get it right. \n', numGuesses);
end
end
rho01 = p01/(R*T01); %Stagnation density
rho1 = rho/(1+(kc0*M1^2))^kc1; %flow density inlet volute
T1 = T01/(1+(kc0*M1^2)); %static temperature inlet volute
p1 = p01/(1+(kc0*M1^2))^kc2; %static pressure inlet volute
C1 = M1*(kc*R*T1)^0.5; %absolute velocity inlet
mdot = rho1*A1*C1; %mass flow rate inlet volute

Antworten (1)

Benjamin Thompson
Benjamin Thompson am 25 Jan. 2022
rho is not defined. Should it be rho01?

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by