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
![Assume you have a 2 x 1 cell array named Stocks. The top element is a cell array containing a single
row of N character arrays, each of which is the abbreviation for a stock on the New York Stock Exchange.
The bottom element of Stocks is a 3 x N matrix containing information about the stocks listed in the top
row. Each column of this matrix (three values) represents the values of the stock in the corresponding
position in character arrays of the top row of stocks at two different times as well as the number of shares
owned. The top row of this matrix represents the original purchase price, the second row represents the
current price, and the bottom row contains the number of shares. Answer the following questions. Each
should be answered with a single MATLAB statement if possible.
(a) Place the abbreviation of the stock with the highest current price in CurrentHigh.
(b) Place the abbreviation of the stock with the lowest purchase price in Cheapest.
(c) Create a single row M-element cell array named Best containing the abbreviations of all stocks that
have increased in value by more than 25%.
(d) Create a 2 x 1 cell array named Profits. The top element contains the abbreviations of the stocks
found in part (c) above in an M-element single-row cell array, and the bottom element contains an M-
element row vector containing the amount of profit that would be made by selling each stock. (Calculated
by (Current Price – Purchase Price) * Number of shares.)
(e) Place the total profit that would be made by selling all of the shares from the preceding question into
the variable TotalProfits.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0d1d82f5-6dbd-4a85-bd51-7ea53cf9931f%2F70af2a7b-e00f-43fa-97af-536677ae6ad8%2Fyl15z5n_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
. 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
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)