Dot indexing not supported

조회 수: 8 (최근 30일)
Curious Mind
Curious Mind 2019년 11월 10일
답변: Walter Roberson 2019년 11월 10일
Hi,
I have the code:
x.y{2} = b
x is a 10by200 matrix and y is a row vector (1by200) and b is also a row vector (1by200) which has already been extracted.i want want to extract the columns or variables in y from which b corresponds to. when I run the code above Matlab says ‘dot indexing not supported for variables of this type’
Any ideas?
Thank you!
  댓글 수: 1
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 10일
Can you save your workspace using
save('variables')
and attach the variables.mat file here please?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 11월 10일
You would only use
x.y
in one of the following cases:
  1. x is a struct scalar that has a field named y . In this case, x.y would be a copy of the field y from the single x entry.
  2. x is a struct array that has a field named y. In this case, x.y would be a "comma separated list" of all of the fields y from the x entries, in linear indexing order of x . This is not uncommon when extracting information from regionprops() results for example.
  3. x is an object or object array with property named y
  4. x is an object or object array with method named y
The only two cases in which assigning x.y{2} = b would be legal would be:
  1. x is a scalar struct that has a field named y that is a cell array and the second entry of that cell array is being assigned to. However, the syntax does not work if x is a non-scalar struct array
  2. x is a scalar object that has a property named y that is a cell array and the second entry of the property is being assigned to. However, the syntax does not work if x is a non-scalar object
You have indicated that x is a 10 by 200 matrix. Both of the matrix possibilities (x is struct array, x is object array) would generate comma-separated lists when you accessed the field or property y of the array, and using {} indexing of a comma separated list that has more than one entry is not valid.
I cannot tell what you are trying to do. I speculate that you must might possibly want something like
any( x(:,y) == b, 1)
but even that seems unlikely.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by