Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A System of Two Equations Solving a system of equations in several variables is easy in Matlab. We simply make sure the variables are defined

A System of Two Equations
Solving a system of equations in several variables is easy in Matlab. We simply make sure the variables are defined symbolically with syms and then we solve. The difference
between this and solving for one variable is that Matlab manages the result differently. For example to solve the system consisting of the two equations 2x+3y=10 and
5x-y=0, we can type:
% We syms both x and y. Just put a space between them!
syms xy
solve (2**x+3**y==10,5**x-y==0)
If we do this, we get something like:
ans =
struct with fields:
x: [1x1sym]
y: [1x1sym]
[x,y]=solve(2**x+3**y==10,5**x-y==0)
If we run this we get: Warning Note: When we do this we have actually assigned the variables x and y to have actual values, so really they're no longer variables. In light of this it might make more
sense to assign the result to something else, like:
[x soln, ysoln]= solve (2**x+3**y==10,5**x-y==0)
Note: The solve command returns the values in alphabetical order which is why the x is returned first, and then the y second.
You can also access the component variables by name. As in
ans = solve (2**x+3**y==10,5**x-y==0)
ans. x+ ans. y
A System of Three Equations
It's probably easy to see how we would solve a system of more than two equations.
Assignment
Write a script which does all of the following in order:
Declare the variables x and y as symbolic.
Solve the system 5x-2y=2,7x+9y=23 and assign the solution to a1.
Take the tan of the sum of the x part of the solution and the y part of the solution and assign the result to z1.
Take the logarithm base 3 of the y part of the solution and assign the result to z2.
Declare the variables s,t, and u as symbolic.
Solve the system 2s+t+u=10,4s-t+7u=4,s-u=1 and assign the solution to the variables ssoln, tsoln, and usoln.
Calculate es-t+u using the ssoln, tsoln, and usoln parts of the solution and assign the result to z3.
Calculate tan(s+2u) using the ssoln and usoln parts of the solution and assign the result to z4.Write a script which does all of the following in order:
Declare the variables x and y as symbolic.
Solve the system 5x-2y=2,7x+9y=23 and assign the solution to a1.
Take the tan of the sum of the x part of the solution and the y part of the solution and assign the result to z1.
Take the logarithm base 3 of the y part of the solution and assign the result to z2.
Declare the variables s,t, and u as symbolic.
Solve the system 2s+t+u=10,4s-t+7u=4,s-u=1 and assign the solution to the variables ssoln, tsoln, and usoln.
Calculate es-t+u using the ssoln, tsoln, and usoln parts of the solution and assign the result to z3.
Calculate tan(s+2u) using the ssoln and usoln parts of the solution and assign the result to z4.
syms x y
a1= solve (5**x-2**y==2,7**x+9**y==23)
z1=tan(a1.x+a1.y)
please help with the rest

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

More Books

Students also viewed these Databases questions