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

35 ビュー (過去 30 日間)
FPMONT
FPMONT 2015 年 7 月 21 日
コメント済み: Marco Ottina 2022 年 12 月 2 日
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 件のコメント
Marco Ottina
Marco Ottina 2022 年 12 月 2 日
yeah, "float" is the name of "single-precision" in C and C++

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

その他の回答 (1 件)

SIFISO NICHOLUS
SIFISO NICHOLUS 2022 年 5 月 9 日
double Z = 2.55555

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by