No products are associated with this question.
The error should not appear, your code looks to work exept for the part of 'data' , should this instead be value?
test='eye'; value=[1,2,3]; eval([sprintf(test) '=value+1'])
2 3 4
The index exceeds matrix dimension could be related to that you have at some point declared a variable in your workspace ( or funciton or whatever ) with the name of eval.
it should return that eval is a built-in function, if it returns eval is a variable there is the reason for your error. If so just use
This seems like to name the fields within a variable. If I just want to make a variable name from a string, how to do it? Thanks!
EDU>> eval([sprintf(test) '=value+1'])
Index exceeds matrix dimensions.
Looks like it still gave the error. What shall I do?