Functions Matlab, how to modify?
Mostrar comentarios más antiguos
Hi,
so I have two vectors, Q = (a,l,m) and Z = (d,b,c). I have created a function to calculate Z, but the problem is that I don't want the answear to be d= something1, b=something2 and c= something3. I want it to be Z = =[something1, something2, something3] when I call the function.
function [a,l,m]=test1(d,b,c)
a=0;
l=b/sqrt(b^2 + c^2);
m=c/sqrt(d^2 + c^2);
a=a*1;
a=a*-1;
l=l*1;
l=l*-1;
m=m*1;
m=m*-1;
Is it possbible to modify the function in some way to achive this?
2 comentarios
Turlough Hughes
el 24 de Nov. de 2019
You would write
function Z = test1(d,b,c)
% operations to get a,l,m.
Z=[a l m];
end
KALYAN ACHARJYA
el 25 de Nov. de 2019
Editada: KALYAN ACHARJYA
el 25 de Nov. de 2019
function Z = test1(d,b,c)
a=0;
l=b/sqrt(b^2 + c^2);
m=c/sqrt(d^2 + c^2);
a=a*1;
a=a*-1;
l=l*1;
l=l*-1;
m=m*1;
m=m*-1;
Z=[a l m];
fprintf('Z=[%i %i %i]\n',Z);
end
Respuesta aceptada
Más respuestas (1)
Jenny Andersen
el 25 de Nov. de 2019
Editada: Jenny Andersen
el 25 de Nov. de 2019
1 comentario
KALYAN ACHARJYA
el 25 de Nov. de 2019
Editada: KALYAN ACHARJYA
el 25 de Nov. de 2019
Why you have deleted your previous comments, its may confuse to the answer providers? This is answer section, please post your comment in comment section only.
Categorías
Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!