필터 지우기
필터 지우기

What is a double matrix?

조회 수: 106 (최근 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
Zach Hanses
Zach Hanses 2021년 12월 11일
I was told that using the double function will help in the process of getting the 5 year average for precipitation
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
Zach Hanses
Zach Hanses 2021년 12월 11일
double(precipitaiton) ?
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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by