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 个评论
Stephen23
2019-9-29
Read these to know what your code is actually doing, and why the error occurs when you try to access the field time in the non-scalar structure data.timepoints:https://www.mathworks.com/matlabcentral/answers/320713-how-to-operate-on-comma-separated-lists|
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!