Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab Homework 5 Section 1: 1) Write a program that consists of a main script and two functions. 2) The main script should ask the

Matlab Homework 5 Section 1: 1) Write a program that consists of a main script and two functions. 2) The main script should ask the user if they want to solve a set of linear expressions or solve only one expression by substituting values in for variables.3) If the user indicates that they want to solve only one expression by substituting values in for variables, call your exp_solver function described in section 2.4) If the user indicates that they want to solve a set of linear expressions, call the lin_expr_solver function described in section 3. Section 2 1) Ask the user to enter one of the linear expressions and save the expression in a variable.2) Ask the user how many variables are in the expression and save their response.3) Create a cell array ( Use curly brackets { } instead of square brackets [ ] )4) Ask the user to enter each of the variables one at a time and save them into the cell array.5) Create a regular array, and ask the user to enter one value at a time, saving each value into the array. These are the values you will substitute for the variables.a.For example, if you wanted to substitute the values 1 and 2 for the variables x and y, the user would enter one and two and you would save them in an array that looked like this: [1 2]6) Finally, use the subs function to solve the expression by substituting the values the user gave you and write the answer into an output file. The output file should indicate what the user chose to do (linear expression or one expression), what the expression was, what values they used (only the numeric values), and what the answer was, each on separate lines.a.For example, an output file might look like this:Single Expression x^2 + y^2 z 1 2 3 2 Section 3 1) Create 3 symbolic variables x, y, and z.2) Now we will build our equation 1 piece at a time. Start by creating an array to store all of your coefficients and exponents. All of our equations will be in the form of [something (x position)] + [something (y position)] + [something (z position)] = [some answer]3) Ask the user to enter a value for the first coefficient and save it in the 1st position in the array4) Now ask the user to enter a value for the first exponent and save it into the 2nd position in the array. 5) Now repeat steps 3 & 4 for y and z, and save the values in different rows.6) Now ask the user to supply an answer for the equation (ex: x + y + z = 10 this number) 7) Now we need to build our expression by multiplying and raising the correct symbols by the correct values. a.For example, the first two pieces would look like this:expression1 = equation1_array(1,1)*x^equation1_array(1,2)expression1 = expression1 + equation1_array(2,1)*x^equation1_array(2,2)b. Remember that since we are not using strings, you will need to use the double equal sign ( == ) to add the result to the expression.8) Now repeat steps 3 7 to build the next two expressions.9) Now that you have your 3 linear equations, use the solve function to solve for x, y, and z.10) Finally, print the results to an output file. The output file should indicate what the user chose to do (solve linear equations), should list each linear equation on a separate line, should list the result for x, y, and z on separate lines. Deliverables The following files should be included in this homework submission: 1) main.m 2) exp_solver.m 3) lin_exp_solver.m

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions