Question
Setup The following steps will help you set up the lab. 1. In Matlab Select File->New->Script. This will open a new editor window. In the
Setup
The following steps will help you set up the lab.
1. In Matlab Select File->New->Script. This will open a new editor window. In the editor window select File->Save As and name your file Lab12.m.
2. Make sure your name(s) is/are in comments at the top of the file.
Activities
Today, you are going to practice using loops, strings, and learning new functions in Matlab. Specifically, you are going to create a script that can answer users questions about the volumes of simple geometric shapes. Your script should:
1. Repeatedly prompt the user to ask a questions. If the user types 'exit' your script should end (using a = input('Some prompt', 's') takes input as a string.)
2. The format of the user's questions can very but they will always contain key elements:
i. They can ask you to find the volume of a cone, a cylinder, a sphere or a cube. Regardless of how they phrase their question, it will always identify the type of shape they are asking about.
ii. If they ask about a cone, a cylinder, or a sphere their question will have the phrase "radius of " followed by an integer number. If they ask about a cone, a cylinder or a cube their question will contain the phrase "height of " followed by an integer number.
Note: your script should be able to answer questions as different as: "cube height of 12?" and "I was wondering with a height of 15 and maybe a radius of 83 what is the volume of a cone?"
3. You, of course, have to answer their questions.
4. Your script should never crash or hang. If a user asks you a poorly formed question, like one that does not contain a shape or another needed component, you should inform them you can't answer their question and prompt them to ask something else.
5. You have all the coding skills to complete this project but Matlab provides you with tools that might make your job much easier. You may want to spend some time investigating Matlab functions that work with strings. Oh, and use Matlab's pi.
The following steps will help you set up the lab 1. In Matlab Select File->New->Script. This will open a new editor window. In the editor window select File->Save As and name your file Lab12.m 2. Make sure your name(s) is/are in comments at the top of the file. Activities Today, you are going to practice using loops, strings, and learning new functions in Matlab. Specifically, you are going to create a script that can answer users questions about the volumes of simple geometric shapes. Your script should Repeatedly prompt the user to ask a guestions. ?f the user types 'exit' your script should end (using a prompt', 's') takes input as a string.) . input(some 2. The format of the user's questions can very but they will always contain key elements: They can ask you to find the volume of a cone, a cylinder, a sphere or a cube. Regardless of how they phrase their question, it will always identify the type of shape they are asking about. If they ask about a cone, a cylinder, or a sphere their question will have the phrase "radius of " followed by an integer number. If they ask about a cone, a cylinder or a cube their question will contain the phrase "height of followed by an integer number. i. ii. Your script should be able to answer questions as different as: "cube height of 127" and "I was wondering with a height of 15 and maybe a radius of 83 what is the volume of a cone? 3. You, of course, have to answer their questions. 4. Your script should never crash or hang. If a user asks you a poorly formed question, like one that does not contain a shape or another needed component, you should inform them you can't answer their question and prompt them to ask something else. You have all the coding skills to complete this project but Matlab provides you with tools that might make your job much easier. You may want to spend some time investigating Matlab functions that work with strings. Oh, and use Matlab's pi. 5. The following steps will help you set up the lab 1. In Matlab Select File->New->Script. This will open a new editor window. In the editor window select File->Save As and name your file Lab12.m 2. Make sure your name(s) is/are in comments at the top of the file. Activities Today, you are going to practice using loops, strings, and learning new functions in Matlab. Specifically, you are going to create a script that can answer users questions about the volumes of simple geometric shapes. Your script should Repeatedly prompt the user to ask a guestions. ?f the user types 'exit' your script should end (using a prompt', 's') takes input as a string.) . input(some 2. The format of the user's questions can very but they will always contain key elements: They can ask you to find the volume of a cone, a cylinder, a sphere or a cube. Regardless of how they phrase their question, it will always identify the type of shape they are asking about. If they ask about a cone, a cylinder, or a sphere their question will have the phrase "radius of " followed by an integer number. If they ask about a cone, a cylinder or a cube their question will contain the phrase "height of followed by an integer number. i. ii. Your script should be able to answer questions as different as: "cube height of 127" and "I was wondering with a height of 15 and maybe a radius of 83 what is the volume of a cone? 3. You, of course, have to answer their questions. 4. Your script should never crash or hang. If a user asks you a poorly formed question, like one that does not contain a shape or another needed component, you should inform them you can't answer their question and prompt them to ask something else. You have all the coding skills to complete this project but Matlab provides you with tools that might make your job much easier. You may want to spend some time investigating Matlab functions that work with strings. Oh, and use Matlab's pi. 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started