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

In a script file named LASTNAME_PROB1.m, write a script according to the followi

ID: 3828465 • Letter: I

Question

In a script file named LASTNAME_PROB1.m, write a script according to the following specification. Before starting, clear all Workspace variables and the Command Window contents. Given d(x) = (x - 1), (10 - e^x - 1), perform the following using a combination of one or more if-end statements and a for-end statement having a loop variable named x representing values from 4 down -2 in steps of 0.01: Compute the current (scalar) value of a variable named d that represents the current (scalar) value of d(x) corresponding to the current (scalar) value of loop variable x. Compute dMax, the maximum value of d within the range x = [-2, 4]. You may not use any built in functions, including min() or max(). Compute xMax, the value in the range x = [-2, 4] causing dMax to occur. You not use any built-in functions, including min() or max(). Display the value of dMax and xMax to the Command window. Print each value as a real number showing a maximum of 4 digits beyond the decimal point. A sample script output is shown below. In a script file named LASTNAME_PROB2.m, write a script according to the following specification. Before starting, clear all Workspace variables and the Command Window contents. Create a variable named V and assign to it a 100-element row vector where each element in the row vector is a randomly generated integer chosen uniformly from the interval [-100, 200].

Explanation / Answer

dMax = -inf; %initialize to minimum possible value
xMax = -Inf;
for x = 4:-0.01:-2
    d = (x-1)*(10 - exp(x-1));
    if d > dMax %if d is more than max value stored
        dMax = d; %store d in dMax
        xMax = x; %and store corresponding x
    end
end
printf ('dMax = %.4f and xMax = %.4f ', dMax, xMax); %this takes care of 4digit after decimal point

I kept the code as simple as possible. I have also commented the code for you to make things easy. If incase you are still facing problem and need clarification, please feel free to ask me. I shall be glad to help you.

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