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

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question

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

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.
Transcribed Image Text: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.
Expert Solution
Step 1

. 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

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning