- Are matches known to exist? Then perhaps your data is not correct (e.g. missing data, wrong units, etc.), or the matching needs to take into account floating point error (e.g. compare absolute difference against a toleance), or throw an error as this indicates an obvious bug in the input data.
- Perhaps for some values no matches actually exist, in which case you need to add special-case handling to your code.
Unable to perform assignment with 0 elements on the right-hand side.
54 次查看(过去 30 天)
显示 更早的评论
I am having some error with obtain a variable that contain a value from the table with the conditions that th AccelSNEditField input equals on of the values in the first column and to use that row and look at the 2nd column of the table to obtain the value for that variable:
BIA0=mergetables{app.AccelSNEditField == mergetables{:,1},2};
However, I am obtaining this error:
Unable to perform assignment with 0 elements on the right-hand side.
Any suggestions or resolutions?
0 个评论
回答(2 个)
Stephen23
2020-7-20
编辑:Stephen23
2020-7-20
The actual problem is that you think that one (or more) of these values match:
app.AccelSNEditField == mergetables{:,1}
In fact they don't. Zero matches. None. Zilch. Nada.
And then you construct a comma-separated list with zero arrays in it and try to allocate those zero arrays to one array.
Does not compute. Not possible. No can do. Il n'est pas possible.
Solution:
That depends on what the problem is. I can see two main possibilities:
0 个评论
Image Analyst
2020-7-20
app.AccelSNEditField == mergetables{:,1}
is going to product a vector of true or false values, which evaluate to 1 or 0 when used as a numerical index. Evidently some of your comparisons are false, which evaluate to zero. There is no zero index for arrays. You can have the first row, but you cannot have the zeroeth row. In this matrix
m = [1, 2;
3, 4];
The first row is [1, 2], but what is the zeroeth row? There is no zeroeth row. See the FAQ for a thorough discussion:
8 个评论
Image Analyst
2020-7-21
Well we're back to having no matches in the comparison:
app.AccelSNEditField == mergetables{:,1}
when you do this:
BIA0=mergetables{app.AccelSNEditField == mergetables{:,1},2};
It's hard to help when we don't have all the variables. Can you attach them in a .mat file:
AccelSNEditField = app.AccelSNEditField;
save('answers.mat', 'AccelSNEditField', 'mergetables');
Then attach answers.mat with the paper clip icon.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!