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

20 visualizaciones (últimos 30 días)
I want to access the vectors inside a structure and assign them independently to a variable (so each variable is a vector). However, when I try indexing the structure to obtain the first vector I get an error.
Here is what I am doing.
Test 1:
ns = data.NodeSets.Data(1) % Line 17
and I get "Expected one output from a curly brace or dot indexing expression, but there were 3 results."
Test 2:
ns = data.NodeSets.Data{1} % Line 17
and I get "Expected one output from a curly brace or dot indexing expression, but there were 3 results."
Test 3:
data.NodeSets.Data % Line 17
and I get a set of three vectors of type double but I can't assign them to any variable as I am only able to see them in the command window
  4 comentarios
Jon
Jon el 1 de Jul. de 2022
Sorry, but that is all a bit complicated, please just save your variable, which you call "data" in the above question, in a .mat file and attach that.
save data data

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 1 de Jul. de 2022
You just need to explore your structure to understand what is happening. You have 3 NodeSets in your structure. The indexing you are using is trying to return the first value for each NodeSet
You need to also index the NodeSet. The code below returns the first value of the first NodeSet.
load data
ns = data.NodeSets(1).Data(1)
ns = 3
  3 comentarios
Shabnam
Shabnam el 14 de Feb. de 2024
how? i get the error Dot indexing is not supported for variable of this type
Cris LaPierre
Cris LaPierre el 14 de Feb. de 2024
That is a completely different scenario than the one answered here. Please create a new question.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by