Cody

Problem 2668. Assign matrix elements to separate variables

Created by Matthew Eicholtz in Community

Given an input array, return each element of the array as a separate variable. If the number of output arguments (k) is less than the number of array elements, only return the first k elements.

Example

If

A = [1 2 3 4];

then

[B,C,D,E] = matsplit(A)

returns

B = 1
C = 2
D = 3
E = 4

Solution Stats

54.84% Correct | 45.16% Incorrect
Last solution submitted on Jul 11, 2019

Solution Comments