Hello,
precalculate the know values, I gain 40% faster execution time.
Hope helps a bit...
BR
clc, clear, mode(0)
n=1e6
Z=grand(1,n,'nor',0,1);
Z=Z(:);
r=0.9;
tic()
V1=Z;
for ii=2:n;
V1(ii)=r*V1(ii-1)+sqrt(1-r^2)*Z(ii);
end;
toc()
tic()
V2 = Z;
k1 = sqrt(1-r^2).*Z;
for ii=2:n;
Hello,
Is there anyone here that uses to use the last filter() optional argument?
In the example of the thread reminded below:
V = Z;
for i=2:n
V(i) = a*V(i-1) + b*Z(i);
end
the input is Z, the output is V, a and b are fixed parameters.
The filter() description tells:
Syntax
--
Thanks Stéphane
Works fine and fast (I'm speaking about my application :-) )
Paul
EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data
De : users [mailto:users-boun...@lists.scilab.org] De la part de Stéphane
Mottelet
Envoyé : mercredi 7
Hello,
If your matrices are not too big,
diag((M-C)*(N(:,1:2)-C)')
may do the job: it gives the same result as Stéphane's solution
HTH
Denis
[@@ THALES GROUP INTERNAL @@]
Unité Mixte de Physique CNRS / THALES
1 Avenue Augustin Fresnel
91767 Palaiseau CEDEx - France
Tel : +33 (0)1 69 41 58 52
Hello,
Try:
function [Scar_P]=Scalar_product(C, N, M) // Scalar product
Scar_P = (M(:,1) - C(:,1)).*(N(:,1) - C(:,1)) + (M(:,2) -
C(:,2)).*(N(:,2) - C(:,2));
//printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2));
printf("M = (%g,%g)\n",M(1),M(2));
Dear All
Most of the time I've no issue in mixing functions and vectorization, but here
I don't know why it does not work - one can see that using a vector I, the loop
is called only ounce and I do not understand why?
I've spent hours in such case showing I'm not fully at ease with it :-) :-)