Is there a way to avoid writing every variable name when using gather?

2 ビュー (過去 30 日間)
minomi
minomi 2018 年 7 月 10 日
コメント済み: minomi 2018 年 7 月 16 日
I am using tall arrays and gather to extract several variables. For instance, to extract date and time I have used
ds.VariableNames(1:2) = {'date','time'}
and then
[date,time] = gather(tt.date,tt.time)
where tt = tall(ds). I have found a way of linking the data columns to a spreadsheet containing the variable names and the column numbers, which avoids typing
{'date','time'}
but cannot think of a way of a way to avoid typing
tt.date, tt.time, etc
  2 件のコメント
Jan
Jan 2018 年 7 月 10 日
What is "tt"?
minomi
minomi 2018 年 7 月 10 日
Sorry, that is what I've called my tall array. I'll clarify in question.

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

採用された回答

Edric Ellis
Edric Ellis 2018 年 7 月 11 日
You could use
date_and_time = gather(tt);
or
[date, time] = gather(tt.(1), tt.(2));
or if you end up with more variables in tt than you need, you can also do:
date_and_time = gather(tt(:, 1:2));
Not sure if any of these really help...

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by