How can I convert a variable whose value is double to integer or to float?

조회 수: 142 (최근 30일)
How can I convert a variable whose value is double to integer or to float? So I think I can fix the problem:
Undefined function 'roundn' for input arguments of type 'double'.
Error in plot_litho_061015 (line 58) drawLine([0 roundn(z1),2], [0 min(z1)]); hold on; % Vertical line at x = 0;
ps: z1 value= 2601x1double

채택된 답변

bio lim
bio lim 2015년 7월 21일
z1 = rand(2601,1);
int_z1 = int8(z1);
I don't really understand what you mean by "float". Are you refering to single-precision? If so,
single(z1)
In general, MATLAB functions usually require doubles.

추가 답변 (1개)

SIFISO NICHOLUS
SIFISO NICHOLUS 2022년 5월 9일
double Z = 2.55555

카테고리

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