Convert System.Decimal from C# .NET to double
18 次查看(过去 30 天)
显示 更早的评论
Christopher Saltonstall
2023-8-3
评论: Walter Roberson
2024-12-30,20:45
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.
0 个评论
采纳的回答
Christopher Saltonstall
2023-8-3
4 个评论
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()
更多回答(1 个)
Grace Kepler
2024-12-30,16:37
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from .NET 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!