C# array of object indexing in matlab

3 visualizaciones (últimos 30 días)
Observer
Observer el 25 de Ag. de 2014
Comentada: Observer el 26 de Ag. de 2014
In matlab, I have array of c# objects and I want to select the object on index position 1.
doc.Workbook.Worksheets
ans =
ExcelWorksheets with properties:
Count: 3
I tried to use small, curly and square brackets to access the object and I am getting following errors:
Array formation and indexing are not allowed on .NET objects.
doc.Workbook.Worksheets[1]
|
Error: Unbalanced or unexpected parenthesis or bracket.

Respuesta aceptada

Guillaume
Guillaume el 26 de Ag. de 2014
Editada: Guillaume el 26 de Ag. de 2014
Use the Item method:
doc.Workbook.Worksheets.Item(1)
It's part of the IList interface which all arrays implement.
  1 comentario
Observer
Observer el 26 de Ag. de 2014
Your answer is partially correct. If I execute above statement without placing semicolon in end then I get error.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 26 de Ag. de 2014
Try parentheses instead of brackets: doc.Workbook.Worksheets(1)
  1 comentario
Observer
Observer el 26 de Ag. de 2014
I tried this approach and was getting following error: Array formation and indexing are not allowed on .NET objects.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by