請以plot指令畫出一個包含有兩條高斯曲線的圖形,
其σ值分別為1.5、0.5,顏色為紅、藍色。
μ值均為3.5,χ範圍1~6。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear;close all; | |
a=3.5;sigma=1.5; | |
x=1:0.01:6; | |
figure(1) | |
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2)); | |
plot(x,y,'r','LineWidth',1); | |
hold on; % show the plot in the same figure | |
a=3.5;sigma=0.5; | |
x=1:0.01:6; | |
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2)); | |
plot(x,y,'b','LineWidth',1); | |
ylabel('f(x)'); | |
legend('sigma=1.5','sigma=0.5') | |
hold off; | |
grid on; % show the grid line |
No comments:
Post a Comment