Homework help.(User defined functions )

조회 수: 2 (최근 30일)
Ahmad Farghaly
Ahmad Farghaly 2020년 4월 2일
편집: Ahmad Farghaly 2020년 4월 2일
Can anyone help me figure out this homework.
function [add,sub] = Add_Subtract (M1,M2)
add = M1 + M2 ;
sub = M1 - M2 ;
end
This is what's requierd in the homework (Write a MATLAB User defined function code to calculate both the subtraction and addition of 2 matrices (it should check the dimensions of both matrices and return dimensions error if the dimensions does not match)
I know how to write the function and this is what I've done so far
But what i can't understand is how to make the function check the dimensions of both matrices and return dimensions error if the dimensions do not match

채택된 답변

James Tursa
James Tursa 2020년 4월 2일
Hint: See these functions:
doc size
doc isequal
doc error
  댓글 수: 1
Ahmad Farghaly
Ahmad Farghaly 2020년 4월 2일
편집: Ahmad Farghaly 2020년 4월 2일
can you please show me how to use them sorry this is my first week learning matlab and i don't know a whole lot yet

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by