mexFunction return valur error after doing clear all

조회 수: 1 (최근 30일)
Jane Jean
Jane Jean 2012년 4월 10일
Hello,
I'm running C code as mexFunction and the result returned was correct before I added 'clear all'. After adding 'clear all' at the beginning of the compile .m script, certain values of the output matrix became infinitely large, which I guess are addresses instead of the calculated values. Then after omitting 'clear all', the output matrix was correct again.
What could have caused the error? If without 'clear all', the mexFunction gave the correct answer, can I conclude that the C code contains no error?
clear all;
load('parametersForKalmanFilter.mat');
blaslib = fullfile('C:\Program Files\MATLAB\R2011b\extern\lib\win64\microsoft\libmwblas.lib');
lapacklib = fullfile('C:\Program Files\MATLAB\R2011b\extern\lib\win64\microsoft\libmwlapack.lib');
mex('-largeArrayDims', 'kalmanFilter.c', 'mathFunction64.c', 'softConstrainedAddFunctions.c', blaslib, lapacklib)
[output1] = kalmanFilter(varA, varB, varC, varD);

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 4월 10일
Could you replace "clear all" with "clear mex" and see if have similar behavior? That is, having "clear mex" causes issues, but commenting it out gets the right result. If the issue is "clear mex", you could look for things like static/persistent variables in your C code and examine how they are being used.
  댓글 수: 2
Jane Jean
Jane Jean 2012년 4월 10일
clear mex worked once and did not work afterwards...
Jane Jean
Jane Jean 2012년 4월 10일
Sorry, my bad. There were some errors in the .mat file I used. >.<

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by