Question: Need help with a MATLAB coding homework question. It is divided into four sections (a-d) and was told during the lecture that for this coding
Need help with a MATLAB coding homework question. It is divided into four sections (a-d) and was told during the lecture that for this coding homework, there should be 3 Matlab files/function for the code to run? Any help is appreciated, thank you


1. In your previous labs you learnt to model a CSTR with a first order reaction in MATLAB. You also learnt how to find the steady state value of concentration (by substituting t=0 or dC/dt=0 and solving analytically). This strategy is feasible for either a first/second order reaction, but you might find that for higher/fractional orders, you will no longer be able to solve the system analytically. Now consider the following system of a reaction occurring in a CSTR:- dC = vo * (Cin - C) k* (" Eq.4 V dt Where vo = volumetric flow rate into and out of the system = 1 Litre/min V= Volume of reactor= 75 Litres Cin = Concentration of reactant in stream entering reactor = 5 M C = Concentration of reactant in stream within/leaving reactor n= order of reaction occurring in reactor Under steady state conditions, the above equation reduces to: VO * (Cin -C) - k* (n = Eq.5 Perform the following tasks: a. Write a function with the definition: function y = CSTR(k,n, C) which accepts as its arguments the volumetric flow rate, volume of the reactor, concentration of reactant in the input stream, the reaction rate, reaction order and concentration of reactant in output stream, and returns the value of the function: VO * (Cin - C-k* (n V Note: Since the volumetric flow rate, volume of the reactor, and inlet concentration will remain constant for the following questions, you may define them within this function and need not pass them as arguments to this function. b. Write a function with the definition: function y = SSCalc(k,n, CL, CU, Ea) which accepts as its arguments the order of the reaction: n, the lower and upper initial guesses: CL, CU and the acceptable error %: Ea, and gives the value of C at which the concentration in the CSTR reaches steady state (Eq. 5). (Hint: This function will be very similar to your PreLab exercise 2 with only very minor changes.) c. Write a script with the name RunSSCalc.m that performs the following operations: i. Run your SSCalc function with k = 0.1, n = [0.1, 0.2, 0.5, 1, 2, 5), Ea=0.1%. You should decide what values of initial guesses make sense for each system. Store the resulting steady state values in a vector with the name "SSN'. ii. Run your SSCalc function with n= 0.5, k = [0.001, 0.01, 0.05, 0.1, 0.5, 1], Ea=0.1%. Again, use appropriate initial guesses. Store these steady state values in a vector with the name 'SSK'. Note: Ensure that you have 6 distinct steady state values in each of the vectors SSK and SSN. d. Plot SSN vs n and SSK vs k with the subplot function to see how the steady state values change with different orders of reaction and different values of rate constant. 1. In your previous labs you learnt to model a CSTR with a first order reaction in MATLAB. You also learnt how to find the steady state value of concentration (by substituting t=0 or dC/dt=0 and solving analytically). This strategy is feasible for either a first/second order reaction, but you might find that for higher/fractional orders, you will no longer be able to solve the system analytically. Now consider the following system of a reaction occurring in a CSTR:- dC = vo * (Cin - C) k* (" Eq.4 V dt Where vo = volumetric flow rate into and out of the system = 1 Litre/min V= Volume of reactor= 75 Litres Cin = Concentration of reactant in stream entering reactor = 5 M C = Concentration of reactant in stream within/leaving reactor n= order of reaction occurring in reactor Under steady state conditions, the above equation reduces to: VO * (Cin -C) - k* (n = Eq.5 Perform the following tasks: a. Write a function with the definition: function y = CSTR(k,n, C) which accepts as its arguments the volumetric flow rate, volume of the reactor, concentration of reactant in the input stream, the reaction rate, reaction order and concentration of reactant in output stream, and returns the value of the function: VO * (Cin - C-k* (n V Note: Since the volumetric flow rate, volume of the reactor, and inlet concentration will remain constant for the following questions, you may define them within this function and need not pass them as arguments to this function. b. Write a function with the definition: function y = SSCalc(k,n, CL, CU, Ea) which accepts as its arguments the order of the reaction: n, the lower and upper initial guesses: CL, CU and the acceptable error %: Ea, and gives the value of C at which the concentration in the CSTR reaches steady state (Eq. 5). (Hint: This function will be very similar to your PreLab exercise 2 with only very minor changes.) c. Write a script with the name RunSSCalc.m that performs the following operations: i. Run your SSCalc function with k = 0.1, n = [0.1, 0.2, 0.5, 1, 2, 5), Ea=0.1%. You should decide what values of initial guesses make sense for each system. Store the resulting steady state values in a vector with the name "SSN'. ii. Run your SSCalc function with n= 0.5, k = [0.001, 0.01, 0.05, 0.1, 0.5, 1], Ea=0.1%. Again, use appropriate initial guesses. Store these steady state values in a vector with the name 'SSK'. Note: Ensure that you have 6 distinct steady state values in each of the vectors SSK and SSN. d. Plot SSN vs n and SSK vs k with the subplot function to see how the steady state values change with different orders of reaction and different values of rate constant
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
