Hello! How I can use output data from one function as an input for another. And write it in one function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi! Kindly ask to check where I did mistake . I am trying to use output data [A, B, C, D, E] from another function reflection5 (i calculated it in reflection5 function)
in new function planeLocation5 as an input
this is one function file
function [p, Xr, Yr, Zr, Theta, Phi, Plane ] = planeLocation5(A, B, C, D, E)
[A, B, C, D, E] = reflection5(X0, Y0, Z0, Theta0, Phi0); %i believe this should be correct, butit doesnt work
planes(:,:,1) = [0 3 3; 0 0 3; 0 3 0; 0 0 0; 0 0 0];
planes(:,:,2) = [0 0 3; 3 0 3; 0 0 0; 3 0 0; 0 0 0];
.......
end
at the end I will combine in one main
2 comentarios
Stephen23
el 6 de Mzo. de 2023
Why not just call them like this?:
[A, B, C, D, E] = reflection5(X0, Y0, Z0, Theta0, Phi0);
[p, Xr, Yr, Zr, Theta, Phi, Plane ] = planeLocation5(A, B, C, D, E);
Respuestas (1)
Prateekshya
el 30 de Ag. de 2024
Editada: Prateekshya
el 30 de Ag. de 2024
Hello Aknur,
To pass the output of one function to another function as arguments, you need to define and call the functions correctly. Here is a sample code for achieving the same:
function [X, Y, Z] = fun1(a, b, c)
[a, b, c] = fun2(3, 4); % calling fun2 with 3, 4
X = a;
Y = b;
Z = c;
end
function [a, b, c] = fun2(j, k)
a = j;
b = k;
c = j+k;
end
[X, Y, Z] = fun1(1, 2, 3); % calling fun1 with 1, 2, 3
Please make sure that you are following this format. You can place fun1 and fun2 in different files.
I hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!