Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using MATLAB 2. Create vector X= 24.93. Using fprintf create the following outpu

ID: 3852441 • Letter: U

Question

Using MATLAB

2. Create vector X= 24.93. Using fprintf create the following output: I spent $24.93 at the grocery store last night. You MUST use the variable X in your fprintf statement (DO NOT just type in the numbers)! Be sure all of the characters and punctuation match precisely.

3. Create the vector s = [1 -2 5 17 32 8 77]

a. Enter code and execute max(s). What is the output and what does it mean?

b. Enter code and execute [v, p] = max(s). What is the output and what does it mean?

c. Enter code and execute [g, h] = min(s). What is the output and what does it mean? The answers to the questions in a, b & c should be in the comments in your MATLAB script. Be sure to explain clearly

Explanation / Answer

2 Answer)

X = 24.93;
fprintf('I spent $%.2f at the grocery store last night. ', X)

3 a. Answer)

%% The ouput of the code is 77. It means that the max(s) statement
% returns the greatest of the numbers from the given vector s.
s = [1 -2 5 17 32 8 77];
max(s)

3 b. Answer)

s = [1 -2 5 17 32 8 77];
[v p] = max(s)

%% The output is:

% v = 77
% p = 7
%% EXPLANATION %%
% It means the above code returns v = 77 as greatest value in vector s
% and p = 7 as the index of greatest value in the vector.

3 c. Answer)

s = [1 -2 5 17 32 8 77];
[g h] = min(s)

%% The output is:

% g = -2
% h = 2
%% EXPLANATION %%
% It means the above code returns g = -2 as smallest value in vector s
% and h = 2 as the index of the smallest value in the vector.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote