2

e.g. I have a function [A, B, C] = foo(vargin). Now I ONLY want the second return value B. Is there any way to get only B without keeping A and C in place or modifying my function code.

OneZero
  • 11,556
  • 15
  • 55
  • 92

2 Answers2

8

The best way is this: [~, B] = foo(vargin). Works since Matlab 2009b I think

Dan
  • 45,079
  • 17
  • 88
  • 157
5
[~,B,~] = foo(vargin)

I think it doesn't work in older versions of MATLAB, but can't remember for sure when ~ was introduced.

am304
  • 13,758
  • 2
  • 22
  • 40