How to create matrix and solve for answers?

1 次查看(过去 30 天)
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?

采纳的回答

Alan Stevens
Alan Stevens 2020-8-28
% 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 个评论
Alan Stevens
Alan Stevens 2020-8-28
编辑:Alan Stevens 2020-8-28
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 2020-8-28
Thank you once again Sir. Best wishes and stay safe.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by