How to make two mxArray* scalar multiply each other?

2 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by