Question: MATLAB HELP Soil Classification You have been tasked with creating a code that allows a user to determine the classification of a soil based on



MATLAB HELP
Soil Classification You have been tasked with creating a code that allows a user to determine the classification of a soil based on their responses to various questions. You cannot use a menu() to ask the user the questions given (variables Q1-Q12). However, based on the vector of answers inputted to the function (As) your code should still be able to determine the correct soil. As is a 1x12 row vector, where the values in cells 1-12 correspond to the answers to questions 1-12, respectively. Where: 1 corresponds to 'Yes' O corresponds to 'No' Ex: Where; As = [1 001101011 0 1]; Basically means; Yes, No, No, Yes, Yes, No, Yes, No, Yes, Yes, No, Yes Task 1: Validate that the inputted vector (As) is a 1x12 vector containing ONLY 1s and Os: Create a variable L that stores the length of As. Using an if statment, validate that L stores a value of 12. If it does not, create an error telling the user that As was not a vector of length 12. Create a variable Check that stores the logical aray corresponding to the variable As holding ONLY 15 OR Os. Take the sum of Check and store it in the variable FinalCheck. FinalCheck should store a value of 12. If it does not, create an error telling the user that As contained something other and 1s and Os. Task 2: Check the type of soil: To determine the correct soil, your code should use nested if statments to check the answers to the various questions. Create a string Soil that contains the final soil name. The way in which the answers to questions should be checked is listed below: The way in which the answers to questions should be checked is listed below: No Ask Q6 Ask Q3 Ask Q4 Ask Q5 Sandy Loam Question: Yes 1. Does the soil feel or sound noticeably sandy? Ask Q2 2. Does the soil lack all cohesion? Sand 3. Is it difficult to roll the soil into a ball? Loamy Sand 4. Does the soil feel smooth and silky, as well as Sandy Silt Loam sandy? 5. Does the soil mould to form a strong ball that leande Sandy Clay Loam smears without taking a polish? 6. Does the soil mould to form an easily deformed Silt Loam ball, and feel smooth and silky? 7. Does the soil mould to form a strong ball that Ask Q8 smears without taking a polish? 8. Is the soil also sandy? Sandy Clay Loam 9. Is the soil also smooth and silky? Silty Clay Loam 10. Does the soil mould like a plasticine, polish, Ask Q11 and feel very sticky when wet? 11. Is the soil also sandy? Sandy Clay 12. Is the soil also smooth and buttery? Silty Clay Ask Q7 Ask Q10 Ask Q9 Clay Loam Unknown Soil Ask Q12 Clay Function Save C Reset MATLAB Documentation WN i function L, FinalCheck, Soil = Soilclassification(As) 2 Q1 = 'Does the soil feel or sound noticeably sandy?'; Q2 = 'Does the soil lack all cohesion?'; Q3 = 'Is it difficult to roll the soil into a ball?'; 5 04 = 'Does the soil feel smooth and silky, as well as sandy?'; 6 Q5 = 'Does the soil mould to form a strong ball that smears without taking a polish?'; 7 06 = 'Does the soil mould to form an easily deformed ball, and feel smooth and silky?'; 07 = 'Does the soil mould to form a strong ball that smears without taking a polish?'; Q8 = 'Is the soil also sandy?'; 10 09 = 'Is the soil also smooth and silky'; 11 Q10 = 'Does the soil mould like a plasticine, polish, and feel very sticky when wet?'; 12 011 = 'Is the soil also sandy?'; 13 012 = 'Is the soil also smooth and buttery?'; 00 O Code to call your function C Reset 1 Soil = Soilclassification (As)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
