フィルターのクリア

Reading list of words for keywords and indexing those to an array

1 回表示 (過去 30 日間)
Dillon Trimmell
Dillon Trimmell 2021 年 12 月 18 日
コメント済み: Dillon Trimmell 2022 年 1 月 4 日
Im making a code to analyze a raw data sheet and I need to catagorize specfic status's from an array.
I have a long 1,n array filled with charge cycles.
I would like to seperate the CC Dchg to a Discharge array, CC Chg to a Charge Array still.
This is along the lines of what im thinking.
[NUM,Status]=xlsread('Group12_vulcan30PTFE_DMSO_T2 (version 1)','Detail_94_1_1','B:B');
if Status(i)=='CC DChg'
Discharge(1,i)=Statis(i);
elseif Status(i)=='CC Chg'
Charge(1,i)=Status(i);
end
  1 件のコメント
DGM
DGM 2021 年 12 月 18 日
Include an example of the data.
What is the purpose of collecting all the instances of the same string into an array full of identical strings? It might make sense to use the information to build a logical mask or a list of indices for sorting the rest of the data in the spreadsheet, but you never import any other data to manipulate.

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

採用された回答

DGM
DGM 2021 年 12 月 18 日
編集済み: DGM 2021 年 12 月 18 日
For example, consider the spreadsheet with the following cursory amount of example data. Let's say you have some current/temperature/etc data that needs to be sorted by the charging status:
[~,~,raw] = xlsread('chargetest.xls')
raw = 13×2 cell array
{[123]} {'CC DChg'} {[ 13]} {'CC Chg' } {[ 55]} {'CC Chg' } {[321]} {'CC Chg' } {[ 5]} {'CC DChg'} {[ 15]} {'CC DChg'} {[465]} {'CC DChg'} {[ 5]} {'CC Chg' } {[212]} {'CC DChg'} {[ 31]} {'CC Chg' } {[464]} {'CC DChg'} {[ 54]} {'CC DChg'} {[355]} {'banana' }
bankcurrent = cell2mat(raw(:,1));
chargestatus = raw(:,2);
ischarging = strcmp(chargestatus,'CC Chg');
isdischarging = strcmp(chargestatus,'CC DChg');
chargingcurrents = bankcurrent(ischarging)
chargingcurrents = 5×1
13 55 321 5 31
dischargecurrents = bankcurrent(isdischarging)
dischargecurrents = 7×1
123 5 15 465 212 464 54
If you really, truly just wanted an array full of the same strings, you could use the same logical indexing:
abunchofthesamething = chargestatus(ischarging)
abunchofthesamething = 5×1 cell array
{'CC Chg'} {'CC Chg'} {'CC Chg'} {'CC Chg'} {'CC Chg'}
but I don't see the point

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by