Why does my Matlab function only return the first output?

  • Thread starter Thread starter eurekameh
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
3 replies · 2K views
eurekameh
Messages
209
Reaction score
0
I'm having trouble getting two outputs. Here's a simple example:

function [a b] = test2()
a = 2;
b = 5;

When I run the code, I only get the output of a = 2:
>>test2
ans =
2

How can I get b outted as well?
 
Physics news on Phys.org
Sorry, I forgot to add, call the function like so:

[apple,orange] = test2()

since it returns multiple outputs.