Create array u(i) that is max of array x(i) and y(i)

Use the MATLAB environment to write an m-file that inputs a positive integer N and N-dimensional arrays x and y and generates a new N-dimensional array, u, defined as: u(i) = max(x(i), y(i)), i=1,2,...,N.
I'm new to MATLAB so I don't know how to set a multidimensional array to N through loops.

Answers (1)

x = rand(10,10,10);
y = rand(10,10,10);
mxy = max(x,y)
max() works directly on n-dimensional arrays.
doc max
Welcome to MATLAB and Answers.

This question is closed.

Asked:

on 30 Apr 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!