LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Performance Mathscript on a RT Target

Hello,

 

I have a VI with a Mathscript that basically generates two 1-D arrays, which size depends on the inputs.

 

Since I know the size of the arrays in advance, I declare them with the zeros function, after I fill them in a for loop with some calculations.

 

Taking as example a case where both arrays contain 10000 elements, Im seeing that, when executing the VI on a MyRio-1900, the Mathscript takes more than 4 seconds to execute (I'm measuring it with tic toc functions).

 

However, executing the same VI, with the same inputs, in the PC, it needs less than 200ms. 

 

Since the executing time in the RT Target is not suitable for my application, I would like to ask whether the problem could be in the way the code is implemented or maybe the Mathscript engine is in the PC and the communication is what is consuming the time, or simply it is impossible to achieve a better performance on the RT Target with this implementation.

 

Thanks so much in advance for any hint in the issue.

 

Here is the code itself:

 

--------------------------

 

tic
k = abs(X1-X0);

if type == 0
setT = li;
elseif type == 1
a0 = paramV(n-1,1);
b = paramV(n-1,2);
a = a0*k^abs(b);
setT = a*li^b;
elseif type == 2
a0 = paramA(n-1,1);
b = paramA(n-1,2);
a = a0*k^abs(b);
setT = a*li^b;
end

if type >0
setT = setT*C(n-1);
setT = setT*1.1;
end

T = setT*cT*0.90;
t = 0:st:setT;
x = t*0;

for i = 1:length(t)
x(i) = (t(i)^(n - 1)*exp(-t(i)/T))/(T^n*gamma(n));
end

u = ones(1,length(x));
y = conv(u,x);
y = y(1:ceil(length(y)/2));
y = y/y(end);

y = X0+(X1-X0)*y;
n2 = floor(p/st);
te = t(end)+(st:st:p);
t = [t te]; y = [y X1*ones(1,length(te))];

v = [0 diff(y)./diff(t)]; vmax = max(abs(v));
a = diff(abs(v))./diff(t); amax = max(a);
t1 = toc;

 

---------------------------------------------------------------

0 Kudos
Message 1 of 1
(605 Views)