Substitute syms in 2D array to have 3D array
Mostra commenti meno recenti
I have a 2D array of syms and I want to substitute the syms variables with 1D array. How do i do it? If a form a loop it takes a long runtime.
sample code:
syms a b c
arr=[0 0 0;0 0 0;a b c];
a=[1 2 3 4 5]';
b=[2 3 4 5 6]';
c=[5 6 7 8 9]';
subs(arr)
The output should be a 3x3x5 matrix. Please help
I have the following code using loops:
syms a b c
arr=[0 0 0;0 0 0;a b c];
J=zeros(3,3,5);
a1=[1 2 3 4 5]';
b1=[2 3 4 5 6]';
c1=[5 6 7 8 9]';
for i=1:5
a=a1(i);
b=b1(i);
c=c1(i);
J(i)=subs(arr);
end
1 Commento
Azzi Abdelmalek
il 22 Dic 2012
It's not clear
Risposta accettata
Più risposte (1)
Saurav Agarwal
il 23 Dic 2012
0 voti
2 Commenti
Walter Roberson
il 23 Dic 2012
I cannot think of any way of doing this that does not involve a loop.
If you show the loop that you have coded, we can examine it and see if we can suggest improvements.
Saurav Agarwal
il 23 Dic 2012
Categorie
Scopri di più su Code Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!