Two outputs in matlab function

836 Views Asked by At

I'm calling a function with 2 outputs: 2 vectors of different size.

I need to use 2 vector of different size (outside of the function) that are calculate inside of the function.

How can I use both vectors out of that function?

Thanks

1

There are 1 best solutions below

2
On

Lets call the output vectors $X$ and $Y$, say we want to add them (I know they are of different size but this is hypothetical), so we want $X+Y$.

Write the function firstcode and execute the script:

[X,Y]=firstcode;

Z=X+Y;

disp(Z)