

I've got some script, but one of them doesn't work properly. Specifically, HaltonProva gives:
error: invalid use of script in index expression
error: called from:
error: /home/fabio/Matematica/Meshfree/HaltonProva.m at line 19, column 4
where the script and its calls follow (they are in distinct .m files, just listed consecutively here):
%%% HaltonProva.m
% bidimensionale
% x = HaltonSequence(100,2);
% y = HaltonSequence(100,3);
% plot(x,y,'.o')
% axis([0 1 0 1])
% axis square
% tridimensionale
% x = HaltonSequence(500,2);
% y = HaltonSequence(500,3);
% z = HaltonSequence(500,5);
% plot3(x,y,z,'.o')
% axis square
% grid on
% prova con la fill distance
xh = HaltonSequence(25,2);
yh = HaltonSequence(25,3);
hh = FillDistance(xh,yh)
xr = rand(25,1);
yr = rand(25,1);
hr = FillDistance(xr,yr)
%%% HaltonSequence.m
function hs = HaltonSequence(n,b)
hs = zeros(n,1);
for idx = 1:n
hs(idx) = localHaltonSingleNumber(idx,b);
end
%%% FillDistance.m
hX = FillDistance(x,y)
neval = 40;
grid=linspace(0,1,neval);
[xe,ye]=meshgrid(grid);
epoints=[xe(:) ye(:)];
ctrs=[x y];
DM_eval=DistanceMatrix(epoints,ctrs);
hX=max(min(DM_eval'));
%%% localHaltonSingleNumber.m
function hn = localHaltonSingleNumber(n,b)
n0 = n;
hn = 0;
f = 1/b;
while(n0>0)
n1 = floor(n0/b);
r = n0n1*b;
hn = hn + f*r;
f = f/b;
n0 = n1;
end
%%% DistanceMatrix.m
% DM = DistanceMatrix(dsites,ctrs)
% Forms the distance matrix of two sets of points in R^s,
% i.e., DM(i,j) =  datasite_i  center_j _2.
% Input
% dsites: Mxs matrix representing a set of M data sites in R^s
% (i.e., each row contains one sdimensional point)
% ctrs: Nxs matrix representing a set of N centers in R^s
% (one center per row)
% Output
% DM: MxN matrix whose i,j position contains the Euclidean
% distance between the ith data site and jth center
function DM = DistanceMatrix(dsites,ctrs)
[M,s] = size(dsites); [N,s] = size(ctrs);
DM = zeros(M,N);
% Accumulate sum of squares of coordinate differences
% The ndgrid command produces two MxN matrices:
% dr, consisting of N identical columns (each containing
% the dth coordinate of the M data sites)
% cc, consisting of M identical rows (each containing
% the dth coordinate of the N centers)
for d=1:s
[dr,cc] = ndgrid(dsites(:,d),ctrs(:,d));
DM = DM + (drcc).^2;
end
DM = sqrt(DM);
How can I fix it?
Thanks in advance. :)


On 20 Mar 2013, at 16:21, afullo < [hidden email]> wrote:
> I've got some script, but one of them doesn't work properly. Specifically,
> HaltonProva gives:
>
> /error: invalid use of script in index expression
> error: called from:
> error: /home/fabio/Matematica/Meshfree/HaltonProva.m at line 19, column 4/
>
> where the script and its calls follow (they are in distinct .m files, just
> listed consecutively here):
Ciao Fabio,
The error is exactly what the error message says, on line 19 of HaltonProva.m you have:
hh = FillDistance(xh,yh)
but FillDistance is neither a vector that can be indexed as FillDistance(…)
nor a function that takes input arguments in parentheses, but rather a script file,
so this line makes no sense.
BTW, if your file FillDistance.m is really as you wrote it:
%%% FillDistance.m
hX = FillDistance(x,y)
neval = 40;
grid=linspace(0,1,neval);
[xe,ye]=meshgrid(grid);
epoints=[xe(:) ye(:)];
ctrs=[x y];
DM_eval=DistanceMatrix(epoints,ctrs);
hX=max(min(DM_eval'));
there is something very wrong with your code as the script FillDistance is also trying to invoke itself as a function …
Where did you get this code from?
c.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 20 Mar 2013, at 16:21, afullo < [hidden email]> wrote:
> I've got some script, but one of them doesn't work properly. Specifically,
> HaltonProva gives:
>
> /error: invalid use of script in index expression
> error: called from:
> error: /home/fabio/Matematica/Meshfree/HaltonProva.m at line 19, column 4/
>
> where the script and its calls follow (they are in distinct .m files, just
> listed consecutively here):
Ciao Fabio,
The error is exactly what the error message says, on line 19 of HaltonProva.m you have:
hh = FillDistance(xh,yh)
but FillDistance is neither a vector that can be indexed as FillDistance(…)
nor a function that takes input arguments in parentheses, but rather a script file,
so this line makes no sense.
BTW, if your file FillDistance.m is really as you wrote it:
%%% FillDistance.m
hX = FillDistance(x,y)
neval = 40;
grid=linspace(0,1,neval);
[xe,ye]=meshgrid(grid);
epoints=[xe(:) ye(:)];
ctrs=[x y];
DM_eval=DistanceMatrix(epoints,ctrs);
hX=max(min(DM_eval'));
there is something very wrong with your code as the script FillDistance is also trying to invoke itself as a function …
Where did you get this code from?
c.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 20/03/2013 17:14, c. wrote:
> %%% FillDistance.m
>
> hX = FillDistance(x,y)
> neval = 40;
> grid=linspace(0,1,neval);
> [xe,ye]=meshgrid(grid);
> epoints=[xe(:) ye(:)];
> ctrs=[x y];
> DM_eval=DistanceMatrix(epoints,ctrs);
> hX=max(min(DM_eval'));
What about simply adding the keyword 'function' on the first line, like
this :
function hX = FillDistance(x,y)
?
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


It worked just by adding "function". :D
Thanks all. :)

