xxxxxxxxxx
% Define a table with two variables
t = table([1, 2, 3], [4, 5, 6], 'VariableNames', {'A', 'B'});
% Define a user-defined function that squares a number
function y = square(x)
y = x^2;
end
% Apply the square function to each variable of the table using varfun
squared_t = varfun(@square, t)
% The result should be a table with two variables, A and B, containing the squared values of the original A and B variables