Input what was selected.

2 views (last 30 days)
Nathan Formby
Nathan Formby on 7 Nov 2019
Answered: Image Analyst on 10 Nov 2019
Load in the provided data for the species involved in the combustion reaction. Prompt the user to enter the four stoichiometric coefficients a, b, c, and d in a 1x4 vector. Prompt the user to enter a value for the enthalpy ∆?25 at 25 [°C]. Create a menu that asks the user if they (1) know the exit temperature of the reactor and need to solve for the heat transferred by the reactor or (2) know the heat transferred by the reactor and need to solve for the exit temperature. If the user does not select either option, continue asking the user until an option is selected.
If the user chooses to solve for the heat transferred by the reactor, prompt the user to enter the exit temperature ????? of the reactor [°C]. Using
Equation 1
? = ∆?25 +∑{∫ ??(?) ?? ????? 25 }
and Equation 2
??(?) = ? + ?? + ?(T^3)
A=CP.mat(column 1); B=CP.mat(column 2); C=CP.mat(column 3)
, calculate and output the heat transfer ? due to the combustion reaction. You may assume that the reaction completely consumes the reactants – that is, after the reaction only the products of the reaction (carbon dioxide and water) remain and only the products must be considered when calculating the internal energy.
What code am I missing besides the input after menu selection to make run the way I want to?
  2 Comments
darova
darova on 8 Nov 2019
Can you be more specific? What problems are you facing?
Nathan Formby
Nathan Formby on 10 Nov 2019
It wants menu option code, then it wants you to insert a number for what you selected.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 10 Nov 2019
Hint. Adapt/use this snippet. Adapt it by making the obvious modifications so that it uses 4 inputs: a, b, c, and d, instead of only 2.
% Ask user for two floating point numbers.
defaultValue = {'45.67', '78.91'};
titleBar = 'Enter a value';
userPrompt = {'Enter floating point number 1 : ', 'Enter floating point number 2: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
usersValue2 = str2double(caUserInput{2})
% Check usersValue1 for validity.
if isnan(usersValue1)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into usersValue1.
usersValue1 = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nTry replacing the user.\nI will use %.2f and continue.', usersValue1);
uiwait(warndlg(message));
end
% Do the same for usersValue2
% Check usersValue2 for validity.
if isnan(usersValue2)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into usersValue2.
usersValue2 = str2double(defaultValue{2});
message = sprintf('I said it had to be a number.\nTry replacing the user.\nI will use %.2f and continue.', usersValue2);
uiwait(warndlg(message));
end

Categories

Find more on Oil, Gas & Petrochemical in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!