Symbolic integers to access matrices
1 view (last 30 days)
Show older comments
Let AKL be a numerical 81*101 matrix.
The question is: How to access AKL through symbolic integers?
That is to say, if i and j are symbolic variables (that should represent later the indices of the matrix), how to express a newAKL as a function of the indices i and j. So that we may obtain a single numerical value from the newAKL matrix when substituting numerical integer values for i and j.
We don't want this newAKL to be a matrix any more but a sym variable and then a numerical value if substitution has been done on i and j.
By this way, the new AKL can be used in calculation not allowed for matrices as a sym variable and substituted by a numerical value taken from the initial AKL matrix and depending on i and j.
I have tried this without success:
whos AKL
Name Size Bytes Class Attributes
AKL 81x101 65448 double
syms i
syms j
syms newAKL(i, j)
evalin(symengine,'assume(i,Type::Integer)')
evalin(symengine,'assume(j,Type::Integer)')
newAKL=sym(AKL); %failure because newAKL remains a matrix (a sym matrix but still a matrix)
%or,
newAKL(i,j)=AKL(i,j); %also failure because i and j are not integers.(error message:Error using sym/subsindex (line 1367) Indexing input must be numeric, logical or ':'.)
There could be something very simple to get what I want but I'm out of ideas at the moment.
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus 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!