Going from structure to matrix
6 次查看(过去 30 天)
显示 更早的评论
So I'm trying to dynamically solve a matrix and have it so I can reuse it next loop however solve seems to return a structure that I can't dynamically cast back into a matrix.
The only code I've found to do it dynamically fails for reason "CELL2MAT does not support cell arrays containing cell arrays or objects."
%Matlab solver test
NumberOfMasses = 20;
lamda = sym('lamda',[NumberOfMasses NumberOfMasses]);
test = lamda * eye(NumberOfMasses,NumberOfMasses);
eqn = lamda * eye(NumberOfMasses,NumberOfMasses) == eye(NumberOfMasses,NumberOfMasses)*2;
ans = solve(eqn,lamda);
cell2mat(struct2cell(ans))%needs to be a matrix for next loop
Is there something I'm missing to Dynamically cast "ans" back to a matrix? (Preferably without writing code that dynamically builds strings and runs getfield() on the struct)
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!