Gaussian using fspecial('gaussian',h,s)

조회 수: 31 (최근 30일)
azarang asadi
azarang asadi 2019년 10월 4일
답변: Jyothis Gireesh 2019년 10월 7일
Hi,
I'm trying to generate a gaussian with fspecial but I keep on getting the same error:
Error in fspecial (line 8)
LG(i)=fspecial('gaussian',h,s);
Does anybody know what is wrong?
Code:
LG=zeros(20,20);
hsize=[1:20]';
sigma=rand(20,1);
for i=1:20
h=hsize(i);
s=sigma(i);
LG(i)=fspecial('gaussian',h,s);
end

답변 (1개)

Jyothis Gireesh
Jyothis Gireesh 2019년 10월 7일
The fspecial('gaussian',h,s) returns a circularly symmetric gaussian function of size h*h. Since the value of h is updated in each iteration of the for loop, the size of the resulting matrix also changes accordingly. The variable LG(i) can only be assigned a scalar value since LG is declared as a 20*20 matrix of zeros. So the assignment may result in a size mismatch between the left and right sides.
It may also be better to replace the fspecial()” function with imgaussfilt()” function which offers the same functionality.
Please go through the following link to get further information on imgaussfilt()”

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by