Borrar filtros
Borrar filtros

How to create matrix and solve for answers?

1 visualización (últimos 30 días)
Danny Maefengea
Danny Maefengea el 28 de Ag. de 2020
Editada: Alan Stevens el 28 de Ag. de 2020
Hi friends, I was trying to solve the problem below using matrix (system of linear equations) but I couldn't get to the final answers. I have also attached a MATLAB file showing how far I got in trying to solve the problem.
Can any body please help? Thank you so much for your help.
Problem:
Using MATLAB, represent the following using matrix form and solve it.
A local theatre sold out for their show. They sold all 500 tickets for 8, 070.00. The tickets were priced at 15 for students, 12 for children, and 18 for adults. If the band sold three times as many adult tickets as children’s tickets, how many of each type was sold?

Respuesta aceptada

Alan Stevens
Alan Stevens el 28 de Ag. de 2020
% Your equations are:
% A + S + C = 500;
% 18*A + 15*S + 12*C = 8070;
% A = 3*C;
% where A = nbr of adults, B = nbr students, C = nbr children
%
% Set these in the form
% M*ASC = V where
% M = [1 1 1
% 18 15 12
% 1 0 -3 ]
% V = [500
% 8070
% 0 ]
% and
% ASC = [A
% B
% C]
%
% Using Matlab's backslash operator you can then solve for ASC
%
% ASC = M\V
%
% Then extract values for A, S and C
% A = ASC(1); B = ASC(2); C = ASC(3);
  3 comentarios
Alan Stevens
Alan Stevens el 28 de Ag. de 2020
Editada: Alan Stevens el 28 de Ag. de 2020
The script above consists of comment lines!
For M write
M = [1 1 1; 18 15 12; 1 0 -];
for V
V = [500; 8070; 0];
Remove the comment symbol (%) from the ASC = M\V line
ASC = M\V;
Remove the comment symbol from the last line.
Danny Maefengea
Danny Maefengea el 28 de Ag. de 2020
Thank you once again Sir. Best wishes and stay safe.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by