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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education