Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section 1 Write a program that consists of a main script and two functions. The main script should ask the user if they want to

Section 1

Write a program that consists of a main script and two functions.

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.

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.

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

Ask the user to enter one of the linear expressions and save the expression in a variable.

Ask the user how many variables are in the expression and save their response.

Create a cell array ( Use curly brackets { } instead of square brackets [ ] )

Ask the user to enter each of the variables one at a time and save them into the cell array.

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.

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]

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.

For example, an output file might look like this:

Single Expression

x^2 + y^2 z

1 2 3

2

Section 3

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]

Ask the user to enter a value for the first coefficient and save it in the 1st position in the array

Now ask the user to enter a value for the first exponent and save it into the 2nd position in the array.

Now repeat steps 3 & 4 for y and z, and save the values in different rows.

Now ask the user to supply an answer for the equation (ex: x + y + z = 10 this number)

Now we need to build our expression by multiplying and raising the correct symbols by the correct values.

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)

Remember that since we are not using strings, you will need to use the double equal sign ( == ) to add the result to the expression.

Now repeat steps 3 7 to build the next two expressions.

Now that you have your 3 linear equations, use the solve function to solve for x, y, and z.

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:

main.m

exp_solver.m

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

How would we like to see ourselves?

Answered: 1 week ago