How to shorten this code efficiently? (cell array multiple assignation with symbolic variables)
Show older comments
Hi,
I'm working on a code, and a shorter way to do the following will be more than useful.
syms x y;
W=cell(5,5,n); % n is quite a large number, at least 100 or 200
A=[1 0; 0 0]; B=[0 1; 0 0]; C=[0 0; 1 0]; D=[0 0; 0 1]; E=[0 0; 0 0];
x=A; y=A; W(1,1,:)={x y x*x x*y ...} % around 200-300 expressions at least
x=A; y=B; W(1,2,:)={x y x*x x*y ...}
% ... and this continues for all possible combinations of {A,B,C,D,E}
The code follows by using the newly created W cell array. Problem is, that if I want to change the {x y x*x x*y ...} part, I need to rewrite the whole part, therefore if there would be a way to define these in the beginning with some variable, I's need to change only one row.
The second problem is, that I need too many rows to cover all possible combinations of {A,B,C,D,E} with x and y.
Is there a more efficient method to assign these elements to the cell array W? :)
Answers (0)
Categories
Find more on Data Types 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!