Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions