Expression or statement is incorrect--possibly unbalanced (, {, or [.
显示 更早的评论
mean(vertcat(Offline.(sortedRelatedFPindex.(1:k,1).Location));
↑
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
what wrong with the (1:k),1 in this statement.
2 个评论
Bruno Luong
2018-9-26
编辑:Bruno Luong
2018-9-26
probably the preceding dot is wrong (usually we don't indexing array with dot)
And you might be better breaking down your expression for better coding style.
KSSV
2018-9-26
We cannot help unless the classes of input is known...
回答(1 个)
Steven Lord
2018-9-26
There are at least two problems in that line of code.
The first is that you have four ( and only three ).
If we corrected that first problem, what you've written comes very close to valid syntax if all of the following conditions are true:
- Offline is a struct array
- k is 1
- sortedRelatedFPindex is a table or timetable with at least one variable
- The first variable of sortedRelatedFPindex is itself a table or timetable with a variable named Location
- The Location variable of that table or timetable inside sortedRelatedFPindex contains a valid field name for Offline
However, it's not quite close enough to match either of the "Dot Indexing" rows in the documentation page describing accessing data in a table. If that is in fact what you're trying to do, remove the ", 1" inside the parentheses following sortedRelatedFPindex.
k = 1;
t = array2table("Natick", 'VariableNames', {'Location'});
sortedRelatedFPindex = table(t);
Offline = struct('Natick', 17);
y = Offline.(sortedRelatedFPindex.(1:k).Location)
More likely than not, that's not what you're trying to do. If you explain what those variables are (specifically what class and size they are) and what you wanted that line of code to do we may be able to offer a somewhat less complicated way for you to achieve your goal.
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!