Expected one output from a curly brace or dot indexing expression
8 次查看(过去 30 天)
显示 更早的评论
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
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
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 个评论
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
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
2021-12-1
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
2021-12-1
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 Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!