how to get struct array field as a vector and compare the two fields

I have a 1x960 struct array with 3 fields: "IM" , "trialtype", and "memorability"
how can I use the two field "IM" and "memorability" so I can compare them in a graph with "IM" on the x axis and "memorability" on the y

5 件のコメント

Walter Roberson
Walter Roberson 2019 年 11 月 15 日
What are the data types of the fields, and what are the sizes of the individual entries?
Nadiyah Browning
Nadiyah Browning 2019 年 11 月 15 日
What do you mean by what are the data types?
Like whether they are nominal or interval/ratio?
Nadiyah Browning
Nadiyah Browning 2019 年 11 月 15 日
the fields are in a .mat file
Walter Roberson
Walter Roberson 2019 年 11 月 15 日
編集済み: Walter Roberson 2019 年 11 月 15 日
Are they double()? Are they categorical? Are they durations? Are they transfer functions? Are they cell arrays of character vectors that represent dates?
Nadiyah Browning
Nadiyah Browning 2019 年 11 月 15 日
and what do you mean bby sizes? "IM" stands for image (so they have indivdual random number ID names) and the memorability is the score that is a decimal

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

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 15 日

0 投票

Under the assumption that IM and memorability are scalars for each entry, then
IM = [YourStructArray.IM];
memorability = [YourStructArray.memorability];
%as an outside observer I cannot assume that the IM entries are in sorted order
[~, idx] = sort(IM);
IM = IM(idx);
memorability = memorability(idx);
plot(IM, memorability)

2 件のコメント

Nadiyah Browning
Nadiyah Browning 2019 年 11 月 15 日
IM is not scalar, for example the first image (IM) is named 588 the second is labeled (1987) those numbers are random and don't mean anything. How can I change the labels??
Walter Roberson
Walter Roberson 2019 年 11 月 15 日
編集済み: Walter Roberson 2019 年 11 月 15 日
"scalar" means a 1 x 1 array, a single value. As compared to the possibility that an IM entry was, for example, a 48 x 64 x 3 RGB image.
If the numbers are random and don't mean anything, then putting them on the x axes needs to be reconsidered, as they provide no position information.
Perhaps what you want is for the memorability values to be plotted in the same order as the index into the array, but for the IM to be used as the label? If so and the IM are numeric, then
IM = [YourStructArray.IM];
memorability = [YourStructArray.memorability];
plot(memorability);
xticks(1:length(IM));
xticklabels(IM);
set(gca, 'XTickLabelRotation', 90);
setting the rotation to 90 is an attempt to deal with the fact that plotting 960 different arbitrary labels on one plot is not going to be readable on anything less than about a 9000 pixel wide display. If the labels turned out to be orderable without gaps (even if the order does not mean anything) then fewer tick labels could be used.

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

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

質問済み:

2019 年 11 月 15 日

編集済み:

2019 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by