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 2 user-defined 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 (i.e.
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, e.g. res = obj.value 1+ obj.value 2 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 e.g. 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 2 values
% numeric, scalar or 2 arrays with matching sizes
end
% Function/Methods of class are defined
% in methods block
methods
function res = add (obj)
% code addition of 2 values here
end
% code methods of three other basic operations
end
end
Code to call your function ?
sol = basicoperations;
sol. value 1=100;
sol. value 2=50;
sum =add(sol)
difference = subtract (sol)
product = multiply (sol)
quotient = divide(sol)
 In this problem we are programming a class using matlab to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!