Effacer les filtres
Effacer les filtres

Creating two arrays using Arrayfun

1 vue (au cours des 30 derniers jours)
Alexi
Alexi le 28 Jan 2023
Modifié(e) : dpb le 28 Jan 2023
How can I create two array sets with Arrayfun, I am getting an error with this code structure. thanks
%%Simulink Matlab function Block
function [y,x]=fcn(Az,sm,del,w0,gama,wc,D_ws,e,n_xs,n_ys,n_zs,om,s)
a= 1:1:100;
vc=1:1:100;
y=arrayfun(@fcn,mod(a,10)+1,fix((a-1)./10)+1);
x=arrayfun(@fcn,fix((vc-1)./10)+1);
function [b,c]=fcn(ns,nb,nc)
k_x=0.01;
k_y=0.01;
b=-w0*cos(gama(nb))+ (wc-k_x*w0)*cos(gama(nb)) * (e*cosd(Az(nb))+sm(ns)*cosd(Az(nb)+del(nb))) + ((D_ws+k_y*w0)*cos(gama(nb))) * (e*sind(Az(nb))+sm(ns)*sind(Az(nb)+del(nb)));
c=-n_xs*sin(gama(nc))*cosd(Az(nc)+del(nc)) + n_ys*sin(gama(nc)) * sind(Az(nc)+del(nc)) + n_zs*cos(gama(nc)) + (e/om) * (cos(gama(nc)) * (s(2) * cosd(Az(nc)) + s(1)*sind(Az(nc))) - sin(gama(nc))*sin(del(nc))*(s(3)-om));
end
end
  6 commentaires
dpb
dpb le 28 Jan 2023
Modifié(e) : dpb le 28 Jan 2023
Assuming x, y are commensurately-sized arrays, the above would appear to be equivalent to
f=repmat(x(:),m,1)+y(:);
which would be "the MATLAB way"...
Alexi
Alexi le 28 Jan 2023
Thanks for your replies, I'll review it again.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by