mex file giving wrong outputs
이전 댓글 표시
Hi, I am generating a mex file for my State Space equation and running it on GPU. When I am running the mex file, I am getting different outputs than expected.
My State Space Equation is:
function out = stateequation(a,b,c,d,x,u) %#codegen
n = size(u,2);
coder.gpu.kernel()
for i = 1:n
x(:,i+1) = a*x(:,i)+ b*u(:,i); %% State Equation
end
out = c*x(:,1:n)+ d*u(:,1:n); %% Output equation
end
On running this code, I am getting answer as :
24 156 948
24 156 948
24 156 948
I have generated mex file using codegen method as follows:
A = double(zeros(3,3));
B = double(zeros(3,3));
C = double(zeros(3,3));
D = double(zeros(3,3));
X = double(zeros(3,1));
U = double(zeros(3,3));
cfg = coder.gpuConfig('mex');
codegen -args {A,B,C,D,X,U} -config cfg stateequation
But on running this mex file I am getting result as :
156 156 156
156 156 156
156 156 156
Why it is giving different answer? Can Someone help me with this?
Thank you in advance
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!