Given the function y = e-0.4(x-3)^2. Compute the corresponding values of yh. Use the bar(xh,yh,.3) command to produce a bar graph. Next superimpose a continuous bell curve over it by taking one thousand samples of a new variable x again from 0 to 6 with the step size 6/999. Issue the hold on command and then use plot(x,y,’r’,’LineWidth’,2) command. All these commands are listed below.
clear all; close all ; clc xh = 0:6/9:6;
yh = exp(-0.4*(xh-3).^2); bar(xh,yh,0.3);
hold on
x = 0:6/999:6;
y = exp(-0.4*(x-3).^2); plot(x,y,’r’,’LineWidth’,2)
xlabel(’x’);
ylabel(’y’);
axis tight
Use MATLAB to answer and post the code in your response.
code :
output :
raw_code :
clear all; %clear workspace
close all;
clc
xh = 0:6/9:6; %creating xh in [0,6] with 6/9 step
yh = exp(-0.4*(xh-3).^2);
bar(xh,yh,0.3); %to produce bar graph
hold on %to plot on same figure
x = 0:6/999:6;
y = exp(-0.4*(x-3).^2);
plot(x,y,'r','LineWidth',2) %plotting bell curve in red
xlabel('x');
ylabel('y');
axis tight
***do comment for queries and rate me up***
Get Answers For Free
Most questions answered within 1 hours.