how to change datatype of libpointer
7 ビュー (過去 30 日間)
古いコメントを表示
Hi , I am trying to use Matlab and shared library.
If I have a C function which is like below
void * foo(int n);
It's just like that we get a void type pointer containing n int data , returned from foo .
In C , we can change void type to int or double easily.
But how to change type in Matlab ?
I tried
pointer = calllib(lib,'foo',1000);
pointer.datatype = 'uint16Ptr'; %Changing the 'DataType' property of lib.pointer is not allowed.
0 件のコメント
採用された回答
Guillaume
2016 年 3 月 1 日
編集済み: Guillaume
2016 年 3 月 1 日
setdatatype(pointer, 'uint16Ptr', n); %assuming the pointer points to an array of n uint16
should work.
2 件のコメント
vishal sp
2022 年 5 月 6 日
iam getting error for this, Check for missing argument or incorrect argument data type in call to
function 'setdatatype'.
Error in getLineColour (line 14)
setdatatype(image,'uint8Ptr',3);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Call C from MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!