how to convert this code into gpuArray
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Anita pawar
le 10 Juil 2017
Modifié(e) : Joss Knight
le 11 Juil 2017
tic;
z=1:0.5:10;
a=1:0.5:5;
num=kron(z,ones(1,length(a)));
i=1:length(a);
deno=zeros(9,3);
deno(i,1)=1;
deno(i,2)=a(i);
den=repmat(deno,length(z),1);
n=numel(num);
for m=1:n
sys(m)=tf(num(m),den(m,:));
end
bode(sys(m))
0 commentaires
Réponse acceptée
Joss Knight
le 11 Juil 2017
Modifié(e) : Joss Knight
le 11 Juil 2017
A blanket change would be
z=gpuArray.colon(1,0.5,10);
a=gpuArray.colon(1,0.5,5);
num=kron(z,ones(1,length(a),'gpuArray'));
i=gpuArray.colon(1,length(a));
deno=zeros(9,3,'gpuArray');
deno(i,1)=1;
deno(i,2)=a(i);
den=repmat(deno,length(z),1);
n=numel(num);
for m=1:n
sys(m)=tf(num(m),den(m,:));
end
bode(sys(m))
I believe you can vectorize away the loop for tf using cell arrays, but you probably won't gain much from that. There's no benefit using gpuArray input to tf anyway.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Switches and Breakers dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!