Effacer les filtres
Effacer les filtres

double型とch​ar型([])が混在​した変数の最小値抽出

4 vues (au cours des 30 derniers jours)
Shinij Kumagai
Shinij Kumagai le 24 Déc 2020
Commenté : Shinij Kumagai le 24 Déc 2020
Table型の中で、double型(数値)とchar型([])が混在している変数の最小値を抽出したいです。
ファイルの数が10個あり、それぞれのファイルで、数値と[]の数は、違います。
[]は、全て数値行数の後に、格納されています。
例えば、ある変数では、下記の様に格納されています。
8030.50000000000
8031.10000000000
8030.80000000000
8030.10000000000
8030.30000000000
8030.20000000000
8030.30000000000
8029.70000000000
8031.10000000000
[]
[]
[]
[]
[]
[]

Réponse acceptée

Kojiro Saito
Kojiro Saito le 24 Déc 2020
cellfunとisemptyで空文字列の行番号を抜き出し、文字列の行を削除し、セル配列を数値に変換してから最小値を取得できます。
load('File.mat')
idx = cellfun(@isempty, TTable.Ne); % []の空文字列のインデックスを抽出
TTable(idx, :) = []; % []が含まれている行を削除
TTable.Ne = cell2mat(TTable.Ne); % セル配列を数値配列に変換
m = min(TTable.Ne); % TTable.Neの最小値を計算
  1 commentaire
Shinij Kumagai
Shinij Kumagai le 24 Déc 2020
ありがとうございます。無事に実行できました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur データ型の変換 dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!