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 comentarios

Bruno Luong
Bruno Luong el 26 de Sept. de 2018
Editada: Bruno Luong el 26 de Sept. de 2018
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
KSSV el 26 de Sept. de 2018
We cannot help unless the classes of input is known...

Iniciar sesión para comentar.

Respuestas (1)

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.

Categorías

Etiquetas

Preguntada:

el 26 de Sept. de 2018

Respondida:

el 26 de Sept. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by