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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2019-9-29
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 个评论
Zeynab Mousavikhamene
编辑:Zeynab Mousavikhamene 2019-9-30
@ 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 2019-9-30
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 ?)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by