フィルターのクリア

Need help concatenating data with struct field name?

4 ビュー (過去 30 日間)
flemingtb
flemingtb 2018 年 11 月 5 日
回答済み: flemingtb 2018 年 11 月 5 日
I have a struct (s) with Field (name) i'm looking to create a 'name' array so that i can concatenate it with data. the field 'name' is file names and the data is range values calculated from each file.
How can i place the files names in column (1) and the range values that go with each name in column (2)?
  2 件のコメント
Stephen23
Stephen23 2018 年 11 月 5 日
編集済み: Stephen23 2018 年 11 月 5 日
What have you tried so far?
Stephen23
Stephen23 2018 年 11 月 5 日
flemingtb's "Answer" moved here:
I know the field names for the struct. I tried
F = theFiles.name
that only gives me the name of the first filename in the column.
I also tried
F = ([theFiles.name])
Which is closer, it lists all of the file names but they are not indexed, they are displayed like a huge string.

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

採用された回答

Stephen23
Stephen23 2018 年 11 月 5 日
編集済み: Stephen23 2018 年 11 月 5 日
Create a cell array from the structure field:
names = {s.name}
This syntax uses a comma-separated list:
Once you read them you will understand that my answer is equivalent to this:
C = {s(1).name, s(2).name, s(3).name,..., s(end).name}
  1 件のコメント
flemingtb
flemingtb 2018 年 11 月 5 日
that worked great for getting the file names into a cell array. Now i have two options, i need to combine this cell array with the data. The data is a 45x1 double, the file names are 45x1 cell, they are not playing nice with each other.
Is it a data format issue?

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

その他の回答 (1 件)

flemingtb
flemingtb 2018 年 11 月 5 日
Ah i think i've got it.
out = [FileNames,num2cell(data)]

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by