Matlab function input define
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to define a matlab function that can generate the deformation gradients etc...so I wrote something like this
function [F,R,U]=deformationgradients[X,Y,Z]
However, I want X,Y,Z of the inputs could be any functions like X=ax^2 or X=xyz or X=z+6; Y=ax+by or Y=6z+3x; Z=x^2 or Z=y+z; where capital X,Y,Z are the total displacements in x,y,z direction.
How can I do that?
0 commentaires
Réponses (1)
Richard Zappulla
le 30 Mar 2017
In my opinion, I would look at passing function handles into your function for X, Y, or Z. The workflow would look something like this:
X = @(x,y,z)(x.*y.*z);
Y = @(x,z)(6.*z + 3.*x);
Z = @(y,z)(y+z);
[F,R,U] = deformationgradients(X,Y,Z,x,y,z);
If you plan on handling vector data, note the ".*" (element-wise multiplication) inside each function. If you are planning on performing matrix-multiplication, remove the ".". Then inside your function, it could look something like:
function [F,R,U] = deformationgradients(X,Y,Z,x,y,z)
someVar1 = X(x,y,z);
someVar2 = X(x,y,z) + Y(x,z);
.
.
.
end
where X,|Y|,and Z are the function handles and x,|y|, and z are data.
Hope this is what you are looking for.
1 commentaire
Stephen23
le 30 Mar 2017
Modifié(e) : Stephen23
le 30 Mar 2017
It would probably be simpler to define each function to accept all of x, y, and z, even if they are not used:
X = @(x,y,z)(x.*y.*z);
Y = @(x,y,z)(6.*z + 3.*x);
Z = @(x,y,z)(y+z);
This will make calling them inside the function consistent, and make the function more versatile.
Voir également
Catégories
En savoir plus sur Calendar 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!