フィルターのクリア

Extract two frist numbers form a column

1 回表示 (過去 30 日間)
Amina Ag
Amina Ag 2021 年 5 月 26 日
コメント済み: Amina Ag 2021 年 5 月 27 日
Hi,
I have a column with 400 000 variables that look something like this:
68.092
67.011
76.949
etc.
I would like to extract the two first numbers into a new column such that I get a column that looks like this:
68
67
76
If it matters, the column is categorical.

回答 (2 件)

KSSV
KSSV 2021 年 5 月 26 日
A = [68.092
67.011
76.949] ;
integ = floor(A);
fract = A-integ;
  1 件のコメント
Amina Ag
Amina Ag 2021 年 5 月 27 日
Thank you for your reply! Unfortunately the floor function only returns me NaNs.

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


EmirBeg
EmirBeg 2021 年 5 月 26 日
編集済み: EmirBeg 2021 年 5 月 26 日
If it's categorical you need to convert it to doubles first.
A = categorical([68.092; 67.011; 76.949]); %Creating your categorical Array.
B = double(string(A)); %Converting and shortening it.
B = floor(B);
B =
68
67
76
Hope it works. Pozdrav.
  1 件のコメント
Amina Ag
Amina Ag 2021 年 5 月 27 日
Hi Emir,
Thank you for your reply. Converting to double only returnes me NaNs and therefore the floor function does not work either. I managed to do it in another program though but highly appreciate your time and response.
Hvala puno! Pozdrav.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by