Expected one output from a curly brace or dot indexing expression, but there were 12 results.

1 view (last 30 days)
I have a table and want to plot cellcount (y) per radius(x). I want to say choose all "cellcount.perhexagon" at final time and plot it versus x.
I want to plot a figure and use this command:
plot(Acc_cellcount.radius(Acc_cellcount.time==data.timepoints.time(end))),cellcount.perhexagon(Acc_cellcount.time==data.timepoints.time(end)))
but I recieve above error. How can I make it to extract all "cellcounts" and "radisu" of the final time not single the end point?
  4 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 29 Sep 2019
Acc_cellcount.time is a column vector of values.
data.timepoints is a non-scalar array. data.timepoints.time asks for structure expansion, and nearly is the equivalent of writing
data.timepoints(1).time, data.timepoints(2).time, data.timepoints(3).time, .... data.timepoints(12).time
at that point. data(timepoints.time(end) is not permitted because () indexing of non-scalar structure expansion is not permitted. If it were permitted, your command would be something like
Acc_cellcount.time==data.timepoints(1).time(end),data.timepoints(2).time(end),data.timepoints(3).time(end)
and so on.
If you are trying to compare each entry in Acc_cellcount.time to the corresponding data.timepoints.time's last entry, then
tp_times = arrayfun(@(TP) TP.time(end), data.timepoints);
mask = Acc_cellcount.time == tp_times;
plot(Acc_cellcount.radius(mask)), cellcount.perhexagon(mask))
  3 Comments
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 30 Sep 2019
Edited: Zeynab Mousavikhamene on 30 Sep 2019
@ Walter Roberson By the way I added above script to the code and I got error:
Matrix dimensions must agree. for mask = Acc_cellcount.time == tp_times;
size(Acc_cellcount.time)=179 1
size(tp_times)= 12 1
Walter Roberson
Walter Roberson on 30 Sep 2019
I wrote, "If you are trying to compare each entry in Acc_cellcount.time to the corresponding data.timepoints.time's last entry, then" but that does not appear to hold.
You have 179 time entries. You have 12 data.timepoints struct members, each of which has a time entry that is a vector of length not known to us .
It is not at all obvious how you want to compare the 179 entries to the 12 items each with a vector. Even if each of the vectors was length 15 exactly so that the 12 of them together added up to 180 entries, that would not match the 179 of the left hand side.
Is your question whether each of the 179 entries appears somewhere in data.timepoints.time ? Or is your question whether each of the 179 entries appears somewhere in the last element of each of the 12 data.timepoints time vectors (that is, the values now collected in the variable tp_times ?)

Sign in to comment.

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!