%% Element-wise Roots of Matrix
% Create a matrix of bases, X, and a matrix of nth roots, N.

X = [-2 -2 -2; 4 -3 -5]
N = [1 -1 3; 1/2 5 3]

% Each element in X corresponds to an element in N.
%
% Calculate the real nth roots of the elements in X.

Y = nthroot(X,N)

% Except for the signs (which are treated separately), the result is comparable to abs(X).^(1./N). By contrast, you can calculate the complex roots using X.^(1./N).
% Copyright 2012 The MathWorks, Inc.