A task that requires multiple outputs in a specific order.

조회 수: 2(최근 30일)
As a basic level MATLAB user, I could not solve the following problem despite several attempts. Could someone please suggest on how to solve this:
Write a function called corners that takes a matrix as an input argument and returns four outputs: the elements at its four corners in this order: top_left, top_right, bottom_left and bottom_right. Solve without using loops and if-statements.
See an example run below:
>> [a, b, c, d] = corners ([ 1 2; 3 4])
a =
b =
c =
d =

채택된 답변

David Fletcher
David Fletcher 2021년 5월 19일
function [a, b, c, d] = corners(matrix)
It's worth going through the Matlab Onramp course to get an idea of basic indexing - this is fundamental to understanding how to use Matlab
  댓글 수: 1
Nauman Ali Khan Khilji
Nauman Ali Khan Khilji 2021년 5월 20일
Thanks alot! I'll check out the Matlab Onramp course as well.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by