What is a double matrix?

154 ビュー (過去 30 日間)
Zach Hanses
Zach Hanses 2021 年 12 月 11 日
コメント済み: Awais Saeed 2021 年 12 月 11 日
I have data that I need to convert into a double matrix. How do I do that ?
  5 件のコメント
Awais Saeed
Awais Saeed 2021 年 12 月 11 日
Decimal point data (aka floating pointer numbers) can be represented as either single precision numbers or double precesion numbers. Single precision data takes 32bits in memory while double precision data takes 64bits. The greater the number of bits, the higher the accuracy. But you can easy tell that double precision costs you more memory. Read more here.

サインインしてコメントする。

回答 (3 件)

KSSV
KSSV 2021 年 12 月 11 日
If it is a string, read about str2num, str2double.
If it is a single, use double.
If it is a sym class, use double.
  3 件のコメント
KSSV
KSSV 2021 年 12 月 11 日
編集済み: KSSV 2021 年 12 月 11 日
In MATLAB every variable has a class. You can get the class using the function class......the numbers i.e. floatingpoint numbers can be single or double. If your precipitation is a single, and you want it to double, yes use:
double(precipitaiton)

サインインしてコメントする。


Awais Saeed
Awais Saeed 2021 年 12 月 11 日
A = magic(4) % data type is double
A = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
s = single(A) % convert double to single
s = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
d = double(s) % convert single to double
d = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
whos
Name Size Bytes Class Attributes A 4x4 128 double d 4x4 128 double s 4x4 64 single

Walter Roberson
Walter Roberson 2021 年 12 月 11 日
retime() works fine with single precision.
dates = datetime('2000-01-01') + calmonths(0:3:35).'
dates = 12×1 datetime array
01-Jan-2000 01-Apr-2000 01-Jul-2000 01-Oct-2000 01-Jan-2001 01-Apr-2001 01-Jul-2001 01-Oct-2001 01-Jan-2002 01-Apr-2002 01-Jul-2002 01-Oct-2002
data = randn(size(dates), 'single')
data = 12×1
-0.9242 -0.7978 -0.6076 -1.3254 -0.8482 1.1801 -1.7518 -1.1227 -0.5025 -1.3097
TT = timetable(dates, data)
TT = 12×1 timetable
dates data ___________ ________ 01-Jan-2000 -0.92422 01-Apr-2000 -0.79782 01-Jul-2000 -0.60761 01-Oct-2000 -1.3254 01-Jan-2001 -0.84822 01-Apr-2001 1.1801 01-Jul-2001 -1.7518 01-Oct-2001 -1.1227 01-Jan-2002 -0.50246 01-Apr-2002 -1.3097 01-Jul-2002 0.87082 01-Oct-2002 0.73953
TT5 = retime(TT, 'yearly', 'mean')
TT5 = 3×1 timetable
dates data ___________ _________ 01-Jan-2000 -0.91377 01-Jan-2001 -0.63564 01-Jan-2002 -0.050449

カテゴリ

Find more on Data Type Conversion in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by