Question

Given the following system of equations: a1x1 + b1x2 + c1x3 = d1 a2x1 + b2x2...

Given the following system of equations:

a1x1 + b1x2 + c1x3 = d1

a2x1 + b2x2 + c2x3 = d2

a3x1 + b3x2 + c3x3 = d3

Write a MATLAB program to find solutions for : x1, x2 and x3. For any value of a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2 and d3. Your program must ask the user to enter at run time the coefficients of your systems.

Homework Answers

Answer #1

MATLAB code is given below in bold letters.

clc;
close all;
clear all;


% prompt the user to enter the coefficients
a1 = input('Enter a1: ');
a2 = input('Enter a2: ');
a3 = input('Enter a3: ');

b1 = input('Enter b1: ');
b2 = input('Enter b2: ');
b3 = input('Enter b3: ');

c1 = input('Enter c1: ');
c2 = input('Enter c2: ');
c3 = input('Enter c3: ');

d1 = input('Enter d1: ');
d2 = input('Enter d2: ');
d3 = input('Enter d3: ');


% Now solve the equations using matrix form
% define matrix A abs B as follows
A = [a1 a2 a3;b1 b2 b3;c1 c2 c3];
B = [d1;d2;d3];
if(det(A)==0)
error('The determinant of A is zero!!!');
else
x = A^1*B
end

command window:

Enter a1: 1
Enter a2: 2
Enter a3: 3
Enter b1: 4
Enter b2: 5
Enter b3: 6
Enter c1: 7
Enter c2: 8
Enter c3: 9
Enter d1: 10
Enter d2: 11
Enter d3: 12

x =

68 (x1)
167 (x2)
266 (x3)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
MATLAB: Do the following with the provided .m file (a) In the .m file, we have...
MATLAB: Do the following with the provided .m file (a) In the .m file, we have provided three questions. Make sure to answer them. (b) Now on the MATLAB prompt, let us create any two 3 × 3 matrices and you can do the following: X=magic(3); Y=magic(3); X*Y matrixMultiplication3by3(X,Y) (c) Now write a new function in MATLAB called matrixMultiplication that can multiply any two n × n matrix. You can safely assume that we will not test your program with...
MATLAB: Do the following with the provided .m file (a) In the .m file, we have...
MATLAB: Do the following with the provided .m file (a) In the .m file, we have provided three questions. Make sure to answer them. (b) Now on the MATLAB prompt, let us create any two 3 × 3 matrices and you can do the following: X=magic(3); Y=magic(3); X*Y matrixMultiplication3by3(X,Y) (c) Now write a new function in MATLAB called matrixMultiplication that can multiply any two n × n matrix. You can safely assume that we will not test your program with...
If the determinant of the 3x3 matrix [2c1 -2c2 2c3; a1+6c1 -a2-6c2 a3+6c3; -b1 b2 -b3]...
If the determinant of the 3x3 matrix [2c1 -2c2 2c3; a1+6c1 -a2-6c2 a3+6c3; -b1 b2 -b3] is -16, what is the determinant of the 3x3 matrix [a1 b1 c1; a2 b2 c2; a3 b3 c3]?
Find two linearly independent solutions of 2x2y′′−xy′+(−2x+1)y=0,x>0 of the form y1=xr1(1+a1x+a2x2+a3x3+⋯) y2=xr2(1+b1x+b2x2+b3x3+⋯) where r1>r2. Enter r1=...
Find two linearly independent solutions of 2x2y′′−xy′+(−2x+1)y=0,x>0 of the form y1=xr1(1+a1x+a2x2+a3x3+⋯) y2=xr2(1+b1x+b2x2+b3x3+⋯) where r1>r2. Enter r1= a1= a2= a3= r2= b1= b2= b3= Note: You can earn partial credit on this problem.
A student will randomly select 5 cards from a deck of 52 cards. Each card is...
A student will randomly select 5 cards from a deck of 52 cards. Each card is uniquely identified by a label which is a combination of a letter (one of the following: A, B, C, D) followed by a number (one of the following: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13). The labels on the cards are A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, B1, B2, B3, B4,...
A student will randomly select 5 cards from a deck of 52 cards. Each card is...
A student will randomly select 5 cards from a deck of 52 cards. Each card is uniquely identified by a label which is a combination of a letter (one of the following: A, B, C, D) followed by a number (one of the following: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13). The labels on the cards are A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, B1, B2, B3, B4,...
Question (excel) 1. Add a worksheet to the file and call it Output. 2. In the...
Question (excel) 1. Add a worksheet to the file and call it Output. 2. In the Output sheet: a. enter first name in cell A1.     b. enter last name in cell B1. 3. Record a macro. Call your macro CIS308Exam3. Within your macro, do the following:      a. In cell C1, use a formula to concatenate A1 and B1 with a space in between     b. Stop recording. 4. Open your macro in Visual Basic edit mode. Copy your...
Suppose the initial conditions of the economy are characterized by the following equations. In this problem,...
Suppose the initial conditions of the economy are characterized by the following equations. In this problem, we assume that prices are fixed at 1 (the price index is 100 and when we deflate, we use 1.00) so that nominal wealth equals real wealth. 1) C = a0 + a1 (Y - T) + a2 (WSM) + a3 (WRE) + a4 (CC) + a5 (r) 1’) C = a0 + a1 (Y - 200) + a2 (10,000) + a3 (15,000) +...
(1 point) Match the following nonhomogeneous linear equations with the form of the particular solution yp...
(1 point) Match the following nonhomogeneous linear equations with the form of the particular solution yp for the method of undetermined coefficients.   ?    A    B    C    D      1. y′′+y=t(1+sint)   ?    A    B    C    D      2. y′′+4y=t2sin(2t)+(5t−7)cos(2t)   ?    A    B    C    D      3. y′′+2y′+2y=3e−t+2e−tcost+4e−tt2sint   ?    A    B    C    D      4. y′′−4y′+4y=2t2+4te2t+tsin(2t) A. yp=t(A0t2+A1t+A2)sin(2t)+t(B0t2+B1t+B2)cos(2t) B. yp=A0t2+A1t+A2+t2(B0t+B1)e2t+(C0t+C1)sin(2t)+(D0t+D1)cos(2t) C. yp=Ae−t+t(B0t2+B1t+B2)e−tcost+t(C0t2+C1t+C2)e−tsint D. yp=A0t+A1+t(B0t+B1)sint+t(C0t+C1)cost
You are coding a simple game called Pig. Players take turns rolling a die. The die...
You are coding a simple game called Pig. Players take turns rolling a die. The die determines how many points they get. You may get points each turn your roll (turn points), you also have points for the entire game (grand points). The first player with 100 grand points is the winner. The rules are as follows: Each turn, the active player faces a decision (roll or hold): Roll the die. If it’s is a: 1: You lose your turn,...