필터 지우기
필터 지우기

C++ pointers and variables

조회 수: 1 (최근 30일)
Carlos
Carlos 2017년 4월 3일
댓글: Guillaume 2017년 4월 4일
Dear experts,
I am trying to convert the following C++ code to a matlab code:
double buffer = 72.0;
double *pBuffer = &buffer;
t = sizeof(buffer));
Does anyone know to solve this question?
Thank you in advance.
Carlos

채택된 답변

Jan
Jan 2017년 4월 3일
buffer = 72;
You do neither need a pointer in Matlab nor does the the size of the type matter.
  댓글 수: 4
Carlos
Carlos 2017년 4월 4일
Thank you Jan. I made it.
Guillaume
Guillaume 2017년 4월 4일
If you're using this filexchange sizeof you're using it incorrectly. The correct code should have been:
calllib(libstring,'SetSystemParameter',MAXIMUM_RANGE,pRecord31,sizeof('double'));
Or you could just not have bothered and pass 8 directly, since scalar double are always 8 bytes.
Note that matlab may have been clever enough to automatically make the conversion from double to void pointer, so possibly this may have been enough:
value = 72;
calllib(libstring,'SetSystemParameter',MAXIMUM_RANGE, value, 8)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by