can u help me solve my matlab assignment? im really frustrated with it
ENG1060 Assignment Page 1 of 10 ENG1060 ASSIGNMENT – S2 2019 Due: 11:00PM (Sharp), Friday 18th October 2019 (Week 11) Late submissions: A 10% penalty (-1 mark) per day, or part thereof, will be applied. No submissions will be accepted once the penalty has reached 50%. GUIDELINES This assignment is to be completed INDIVIDUALLY. Students are advised to review Monash University's policies on academic integrity, plagiarism and collusion. Plagiarism occurs when you fail to acknowledge that the ideas or work of others are being used. Collusion occurs when you work in a manner not authorised by the teaching staff. Again, this is an individual assignment. Do not share your code or code with others. You may discuss ideas with your peers but the coding must be your own. You must have full understanding of it. All assignments will be checked using the Measure of Software Similarity (MOSS) plagiarism and collusion detection software. Files with high similarity counts will be flagged and reviewed. In the event of suspected misconduct, the case will be reported to the Chief Examiner and the student's unit total will be withheld until the case has been reviewed and a decision has been finalised by the Associate Dean of Education (Engineering). INSTRUCTIONS Download the assignment template files from Moodle and modify the code within the template files (e.g. Q1a.m, Q1b.m, etc.). DO NOT rename the template m-files or modify run_all.m. Check your solutions to Q1 and Q2 by running run_all.m and ensuring all questions are answered as required. Do not use close all, clear all, clc in any m-files except run_all.m. The variables will remain in the workspace upon each file call. This assignment assesses your ability to apply concepts taught in ENG1060. Therefore, do not use any toolboxes or functions that are not taught in ENG1060, unless otherwise specified. SUBMITTING YOUR ASSIGNMENT Submit your assignment online using Moodle. Read the “Assignment upload instructions.pdf” to prepare your ZIP file for submission. Your ZIP file (not .rar or any other format) must include the following attachments: a. Solution m-files for assignment tasks (e.g. run_all, Q1a.m, Q1b.m, etc.) b. Any additional function files required by your m-files (e.g. comp_trap.m, heun.m, newraph.m, etc.) c. All data files needed to run the code including the input data provided to you (e.g. data1.txt, data2.csv, etc.) Your assignment will be marked in your usual computer lab session during Week 12. YOU MUST ATTEND TO HAVE IT MARKED. IF YOU DO NOT ATTEND, YOUR ASSIGNMENT MARK WILL BE ZERO. YOUR ZIP FILE WILL BE DOWNLOADED FROM MOODLE AT THE END OF WEEK 11 AND ONLY THESE FILES WILL BE MARKED. We will extract (unzip) your ZIP file and mark you based on the output of run_all.m on a Windows-based system. It is your responsibility to ensure that everything needed to run your solution is included in your ZIP file. Additionally, you will need to ensure that everything runs seamlessly on a Windows-based system (especially if you have used MATLAB on a Mac OS or Linux system). Windows OS computers are available in the computer labs on campus for testing. The assignment will not be downloaded to your individual laptops for marking. https://www.monash.edu/students/admin/policies/academic-integrity ENG1060 Assignment Page 2 of 10 MARKING SCHEME This assignment is worth 10% (1 Mark = 1%) of the unit mark. Your assignment will be graded using the following criteria: 1) run_all.m produces results automatically (additional user interaction only if asked explicitly) 2) Your code produces correct results (printed values, plots, etc…) and is well written. 3) Poor programming practice will result in a loss of up to 2 marks out of 10. 4) Your ability to answer the demonstrator's questions testing your understanding of the questions and the submitted code. 5) This assignment assesses your ability to apply concepts taught in ENG1060. Therefore, do not use any toolboxes or functions that are not taught in ENG1060, unless otherwise specified. ASSIGNMENT HELP 1) You may use the function files that you have written in the labs. 2) You may ask questions in the Discussion Board on Moodle. 3) The m-file templates contain pre-written comments and sections only as a guide. You do not need to follow its structure. You may delete the comments. 4) Hints may also be provided during workshops. 5) Bold text has been used to emphasize important aspects of each task. This does not mean that you should ignore all other text. 6) The questions have been split into sub-questions. It is important to understand how each sub-question contributes to the whole, but each sub-question is effectively a stand-alone task that does part of the problem. Each can be tackled individually. 7) It is recommended that you break down each sub-question into smaller parts too and figure out what needs to be done step-by-step. Then you can begin to put things together again to complete the whole. 8) Solve the question, of part thereof, by hand before attempting to code the solution. ENG1060 Assignment Page 3 of 10 QUESTION 1 [4 MARKS] Background The ideal gas law describes the behaviour of an ideal gas using relationships between pressure ? (Pa), molar volume ? (m3/mol) and temperature ? (K). It is defined by ?? = ?? where ? = 8.314 J/(mol.K) is the ideal gas constant. Non-idealistic behaviour of a gas can be described by the Peng Robinson equations of state, which are defined as: ?? = ??? where ? is the compressibility factor that characterises the non-ideality of the gas at different operating conditions, and ?, ? and ? are the same as those in the ideal gas law. Here ? is solved in the equation ?3 − (1 − ?)?2 + (? − 2? − 3?2)? − (?? − ?2 − ?3) = 0 with ? = ??? ?2?2 ? = ??? ?? The coefficients ? and ? account for gas mixtures (mixtures with more than 1 gas component) through the coefficients ?? and ?? (subscript ? denotes mixed gas), which are defined as ?? =∑ ∑ [????(1 − ???)√????] ? ?≠? ? ?=1 ?? =∑ ???? ? ?=1 where ?? is the mol fraction of component ? in the gas mixture while ??? is the binary interaction parameter between gas pair ? and ?. Finally, the coefficients ? and ? are given by ? = 0.45724 ?2?? 2 ?? {1 + (0.37464 + 1.54226? − 0.26992?2) (1 − √ ? ?? )} 2 ? = 0.07780 ??? ?? where ?? represents the critical temperature, ?? is the critical pressure and ? is the acentric factor of individual gasses. ENG1060 Assignment Page 4 of 10 Data from a database has been downloaded in the three files below. 1. pr_gas.txt contains the gas names the critical pressure Pc (bar) the critical temperature Tc (°C) the acentric factor Ac 2. binary_interaction_parameter.txt contains the binary interaction parameter kij 3. gas_mixtures.xls contains the gas mixture comprised of 3 components the initial temperature Ti (K) and final temperature Tf (K) the initial pressure Pi (Pa) and final pressure Pf (Pa) The composition of each component (totals to 1) Q1a In the Q1a.m file, import the files and create variables for the gas name, critical pressure, critical temperature, acentric factor and the binary interaction parameter. Use fprintf() to print the gas mixture options to the command window. An example output is shown below. Gas mixture 1: CH4 CO2 N2 Gas mixture 2: CO2 O2 H2 … Gas mixture 5: C2H6 C3H8 nC4H10 Note: The textdata field in the imported structures are cells1 and need to be referenced using curly braces {}. Prompt the user for a valid option number. i.e. the option choice should be an integer from 1 to the number of mixtures available. Continue to prompt the user for an option if the input is invalid. Note: You may be provided with a text file that has more than 5 mixture options during marking. However, each mixture will always contain only 3 components. *You should zero figure windows by the end of this task. 1 Cells are similar to matrices except it may contain both numerical data and strings inside a single cell. There are two ways to refer to the elements of a cell array. Enclose indices in smooth parentheses, (), to refer to sets of cells--for example, to define a subset of the array. Enclose indices in curly braces, {}, to refer to the text, numbers, or other data within individual cells. Source: https://au.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html ENG1060 Assignment Page 5 of 10 Q1b In the Q1b.m file, extract the critical pressure in Pa, critical temperature in K and acentric factor for each gas component in the chosen gas mixture. Use fprintf() to print this information for each gas component. An example is shown below. Component 1 [CH4]: Pc = X.XXe+XX Pa, Tc = XXX.XX K, Ac = X.XXXX Component 2 [Ar]: Pc = X.XXe+XX Pa, Tc = XXX.XX K, Ac = X.XXXX Component 3 [CO2]: Pc = X.XXe+XX Pa, Tc = XXX.XX K, Ac = X.XXXX *You