April 12, 2015

[FreeMat] [Matlab] Gaussian function 繪製高斯函數圖形

高斯函數的形式為:
f(x) = a e^{-(x-b)^2/2c^2}


請以plot指令畫出一個包含有兩條高斯曲線的圖形,
其σ值分別為1.5、0.5,顏色為紅、藍色。
μ值均為3.5,χ範圍1~6。


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
view raw gistfile1.txt hosted with ❤ by GitHub

No comments:

Post a Comment

三個逗號俱樂部

《免責聲明》 本部落格不針對任何金融商品進行買賣建議, 內容來自公開資訊觀測站之分享與各大媒體之評論為主, 投資人應審慎評估並獨立判斷,切勿以本部落格資訊作為投資依據。 靜候 時機來臨;瞬間掌握重壓;享受 獲利奔馳。 -------------------------...