Question: In this problem we are programming a class using matlab to perform basic arithematic operations with 2 user - defined values. In the given template,
In this problem we are programming a class using matlab to perform basic arithematic operations with userdefined values.
In the given template, we already defined the name of the class as 'basicoperations' using the classdef command.
Your task is to complete the rest of the class definition. In the properties block, define the attribute names. Both attributes should be accessible from outside of the class ie
keep the default public access, do not change it to private or protected
And in the methods block, write down four basic arithmetic operations functions add subtract, multiply, and divide Note that in your function definitions, you should be operating
both values by calling the object attributes using dot operators, eg res obj.value obj.value for addition.
In the How to call the function code block and code assessments, your class definition will first be instantiated as an object by eg sol basicOperations and then tested for
correctness.
Function
classdef basicoperations
Attributes of a class are defined
in properties block
properties
define class attributes here
attributes of this class are values
numeric, scalar or arrays with matching sizes
end
FunctionMethods of class are defined
in methods block
methods
function res add obj
code addition of values here
end
code methods of three other basic operations
end
end
Code to call your function
sol basicoperations;
sol. value ;
sol. value ;
sum add
difference subtract sol
product multiply sol
quotient dividesol
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
