Convert System.Decimal from C# .NET to double

조회 수: 6 (최근 30일)
Christopher Saltonstall
Christopher Saltonstall 2023년 8월 3일
댓글: Walter Roberson 2024년 12월 30일
I am communicating with a Thorlabs DC servo controller via .NET. When I query the motor position it returns the value in system.decimal format. I found some documentation that briefly mentions this format but doesn't explain how to convert it to a usable numerical value.
How can I can I convert this to something usable?
The returned postion variable is attached.

채택된 답변

Christopher Saltonstall
Christopher Saltonstall 2023년 8월 3일
load 'pos.mat'
import System.*
methodsview('System.Decimal')
System.Decimal.ToDouble(pos)
  댓글 수: 4
Walter Roberson
Walter Roberson 2023년 9월 29일
Notes:
This can only work on Windows
You might need to do the import before the load, so that the class is defined at the time of the load()
Valeriy
Valeriy 2023년 10월 3일
OK, I see it, thank you, it is attached

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

추가 답변 (1개)

Grace Kepler
Grace Kepler 2024년 12월 30일
Here is an example without using "pos.mat".
>> xdecimal = System.Decimal(100.1)
xdecimal =
Decimal with properties:
Scale: 1
Zero: [1×1 System.Decimal]
One: [1×1 System.Decimal]
MinusOne: [1×1 System.Decimal]
MaxValue: [1×1 System.Decimal]
MinValue: [1×1 System.Decimal]
>> xdouble = System.Decimal.ToDouble(xdec)
xdouble =
100.1000
  댓글 수: 1
Walter Roberson
Walter Roberson 2024년 12월 30일
Note that System.Decimal is only available on MS Windows.

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

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by