Expected one output from a curly brace or dot indexing expression
7 views (last 30 days)
Show older comments
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 Comment
Stephen23
on 1 Dec 2021
"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.
Answers (2)
Matt J
on 30 Nov 2021
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 Comments
Matt J
on 30 Nov 2021
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
on 30 Nov 2021
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 Comments
Stephen23
on 1 Dec 2021
Better data design would:
- use one non-scalar structure array rather than lots of separate structures in a cell array.
- move the meta-data (pseudo-indices) into actual indices.
Voss
on 1 Dec 2021
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).
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!