Matlab function input define
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Richard Zappulla
el 30 de Mzo. de 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 comentario
Stephen23
el 30 de Mzo. de 2017
Editada: Stephen23
el 30 de Mzo. de 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.
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!