Please me with this matlab code. %% Variables to be used % Inputs % Stocks - cell array containing % top element - cell array containing single row of stock abbreviations (character arrays) % bottom element - matrix 3 x N matrix of purchase price (row 1), current price (row 2), and number of stocks (row 3) % Outputs % CurrentHight - character array of stock with the highest current price % Cheapest - character array of stock with the lowest purchase price % Best - cell array containing character array of stocks which have increased by 25% in value % Profits - 2 x 1 cell array containing % element 1 - single-row cell array of stocks found in Best % element 2 - single-row vector contain profit from selling each stock in Best % Total Profits - scalar containing total profit from selling all stocks in Best %% Inputs % Generate_Stocks % This script generates the cell array Stocks. % Test Case 1 Stocks = {{'APL' 'BBT' 'ZZT'}; [29.76 11.69 38.06; 23.83 15.77 37.25; 58 48 3]} % Test case output: % CurrentHigh = 'ZZT' % Cheapest = 'BBT' % Best = {'BBT'} % Profits = {{'BBT'}; 195.84} % TotalProfits = 195.84
Please me with this matlab code.
%% Variables to be used
% Inputs
% Stocks - cell array containing
% top element - cell array containing single row of stock abbreviations (character arrays)
% bottom element - matrix 3 x N matrix of purchase price (row 1), current price (row 2), and number of stocks (row 3)
% Outputs
% CurrentHight - character array of stock with the highest current price
% Cheapest - character array of stock with the lowest purchase price
% Best - cell array containing character array of stocks which have increased by 25% in value
% Profits - 2 x 1 cell array containing
% element 1 - single-row cell array of stocks found in Best
% element 2 - single-row
% Total Profits - scalar containing total profit from selling all stocks in Best
%% Inputs
% Generate_Stocks % This script generates the cell array Stocks.
% Test Case 1
Stocks = {{'APL' 'BBT' 'ZZT'}; [29.76 11.69 38.06; 23.83 15.77 37.25; 58 48 3]}
% Test case output:
% CurrentHigh = 'ZZT'
% Cheapest = 'BBT'
% Best = {'BBT'}
% Profits = {{'BBT'}; 195.84}
% TotalProfits = 195.84
. A sample Stocks cell array was created as per the description of the problem for testing purposes and the answers for the given problems were tested on that cell array.
2. The totalProfit is being calculated on the Profits cell array rather than on the Stocks cell array.
3. Any discrepancies in the code can be mentioned in the comments section which will be resolved immediately.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps