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 Center および File ExchangeUnit Conversions についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by