How to make two mxArray* scalar multiply each other?

조회 수: 6 (최근 30일)
wei zhang
wei zhang 2021년 2월 15일
답변: James Tursa 2021년 2월 15일
Hi,
I have a simple step of multiplying two double scalar variables in mex. Why not the type "mxDouble" support multiply? Must I convert the mxDouble to double in c? My sample code is as below. I don't know much about the mx* type data. Thank you.
mxDouble* x = mxGetPr(prhs[0]);
mxDouble* y = mxGetPr(prhs[1]);
plhs[0] = mxCreateDoubleScalar (x*y);
% expression must have arithmetic or unscoped enum type

채택된 답변

James Tursa
James Tursa 2021년 2월 15일
x and y are pointers, so you need to dereference them to get at the double values they point to. So your code should be:
plhs[0] = mxCreateDoubleScalar (*x * *y);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by