Expected one output from a curly brace or dot indexing expression

조회 수: 4 (최근 30일)
Honey
Honey 2021년 11월 30일
댓글: Voss 2021년 12월 1일
Hi,
I want to save my data in a cell file with "n" number of struct and two order dot indexing like below.
But I recived this error. I want to know it is not really possible to use 3 order dot indexing in a mat file?
Data{n}.IMERG(St_Name,1).(St_Name)(month,day)=Data_IMERG;
Error in Pixel_to_Point (line 29)
Data{n}.IMERG(St_Name,1).(St_Name)(month,day)=Data_IMERG;
Expected one output from a curly brace or dot indexing expression, but there were 3 results.
  댓글 수: 1
Stephen23
Stephen23 2021년 12월 1일
"I want to know it is not really possible to use 3 order dot indexing in a mat file?"
It is certainly possible. But one of your cell arrays or structures or indices is non-scalar, and that causes the error.

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

답변 (2개)

Matt J
Matt J 2021년 11월 30일
The issue you are seeing has nothing to do with mat files. The expression that you've shown can only work if n is a scalar.
  댓글 수: 3
Honey
Honey 2021년 11월 30일
Sorry, @Matt J any other suggestion? How can I solve this problem?
Matt J
Matt J 2021년 11월 30일
I suggest you attach a .mat file containing all the variables in that line of code....Data, Data_IMERG, St_Name, month, day ..... so that we can better examine what is happening in that line

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


Voss
Voss 2021년 11월 30일
Is St_Name a length-3 character vector, .e.g., 'acb', by chance? I ask because it doesn't seem likely that St_Name can be used as the name of a field of a struct [".(St_Name)"] and also an index ["IMERG(St_Name,1)"]. I'm guessing it is a length-3 character vector which is used as indices into Data{n}.IMERG, returning 3 results, hence the error.
So I would check that the expression is correct as written, and if it is, let us know what some of these variables are. There is nothing wrong with multiple dot expressions per se.
  댓글 수: 3
Stephen23
Stephen23 2021년 12월 1일
Better data design would:
  1. use one non-scalar structure array rather than lots of separate structures in a cell array.
  2. move the meta-data (pseudo-indices) into actual indices.
Voss
Voss 2021년 12월 1일
@Honey: What kind of variable is Data{n}.IMERG? What do you expect Data{n}.IMERG(St_Name,1) to be?
Like I said, this expression:
Data{n}.IMERG(St_Name,1).(St_Name)(month,day)=Data_IMERG;
is using St_Name as an index into Data{n}.IMERG, which I don't believe is what you intend to do and I believe is the source of the error. The other expression, which works fine:
Data{n}.(St_Name)(month,day)=Data_IMERG;
does not use St_Name as an index into Data{n}.IMERG. Therefore, I suspect you have a syntax error in the first expression. Without knowing what your intent is in writing that expression, I have no way to know what it should be, but the answer to your original question is clear: It is possible to use 3 dot indexing operations in a single expression (regardless of whether the variable is from a .mat file).

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by