In: Computer Science
Write as a script in the editor window of Matlab:
Concession stand. Write a program, ConcessionStand.m, that uses vector-matrix multiplication to tabulate and display the cost of each of the following orders. Assume that a hot dog costs $3.00, a brat costs $3.50, and a Coke costs $2.50.
----------------------------------------------------
hot dogs brats cokes
order 1 2 1 3
order 2 1 0 2
order 3 2 2 2
order 4 0 5 1
% Matlab script that uses vector-matrix multiplication to tabulate and display the cost of each given order
% create a matrix of orders where each row contains number of
hotdogs, brats and coke for a order
% column 1 contains number of hotdogs for the order
% column 2 contains number of brats for the order
% column 3 contains number of coke for the order
order = [2,1,3;1,0,2;2,2,2;0,5,1];
% create a row vector for the cost of one hotdog, brat and coke (in
order)
% row 1 contains cost for 1 hotdog
% row 2 contains cost for 1 brat
% row 3 contains cost for 1 coke
cost = [3;3.5;2.5];
% compute cost for each order using vector-matrix
multiplication
order_cost = order*cost;
% display the order matrix
fprintf('Order : \n');
disp(order);
% display the cost vector
fprintf('Cost : \n');
disp(cost);
% display the order cost vector
fprintf('Order Cost :\n');
disp(order_cost);
%end of script
Output: