File Exchange

image thumbnail

Assign the same values to many output variables

version 1.0 (1.33 KB) by

MANY takes in the variable x and assign it to all the output variables.

1 Download

Updated

View License

MANY takes in the variable x and assign it to all the output variables.

This function works as the equation sign in C++ so that the following expression in C++:

x1 = x2 = x3 = x4 = x5 = 8;

is equivalent to the following expression in MATLAB:

[ x1, x2, x3, x4, x5 ] = MANY( 8 );

Comments and Ratings (2)

Jan Simon

Jan Simon (view profile)

I do not assume that PARFOR is helpful here. Is it? This looks simpler and is faster:
varargout = cell(nargout, 1); varargout(:) = {x};
Anyhow, I'd stay at DEAL.

Eric

Eric (view profile)

Of course

[x1, x2, x3, x4, x5] = deal(8);

using Matlab's built-in deal() function does the same thing.

MATLAB Release
MATLAB 7.10 (R2010a)
Tags Add Tags

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video