Using convpres in MATLAB (single to float conversion)

조회 수: 4 (최근 30일)
Deepayan Bhadra
Deepayan Bhadra 2020년 12월 8일
답변: Sahithi Kanumarlapudi 2020년 12월 14일
X is a 450x1 single type data.
>> temp1 = typecast(X,'float');
Error using typecast
Unsupported data type for conversion.
>> temp1 = double(X);
>> temp1 = convpres(temp1,'Pa','psi');
Undefined function 'convpres' for input arguments of type 'double'.
I looked up all the usual MATLAB casting technique but to no luck. Can someone comment? Thank you.

답변 (1개)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2020년 12월 14일
Hi,
Your question has two parts
1.) Regarding the use of typecast : You can convert 'single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64' to 'single', 'double', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', or 'uint64' (As you can see there is no float in this list). For more info refer to the documentation of typecast here.
2.) Regarding the use of convpres function: In the code snippet that you have provided, temp1 is of type double. But as per the documentation of convpres, the type of first argument 'valuesToConvert' is expected to be float (Floating-point array of size m-by-n values).
Referring to the documentation of convpres might give you more info: https://in.mathworks.com/help/aerotbx/ug/convpres.html
Hope this helps!

카테고리

Help CenterFile Exchange에서 Unit Conversions에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by