3solve using matlab codesSolutionI have answered the questio
3-solve using matlab codes
Solution
I have answered the question in a very simple manner. This method will ensure you to work out problems quickly.
%% FUNCTION CALLING PROGRAM
clc;close all;clear all;
a=input(\'Enter \"a\" value: \');
b=input(\'Enter \"b\" value: \');
display(\'GCD of a and b is: \');
% Calling GCD function
GCD1(a,b)
%% IN ANOTHER PROGRAM CREATE FUNCTION WITH NAME GCD1 AND SAVE IT WITH NAME GCD1.
function [b]=GCD1(a,b)
% Main concept
if a>0 && b>0
r = a - b * floor( a/b );
% Repeat the operation until updates of \' a \' equal updates of \' b \'
while r ~= 0
a = b;
b = r;
% This is the main concept iterated
r = a - b * floor( a/b );
end
else
b=0;
end
