From 4b12b12c0badef3d3623ccbe58ae855957e16b11 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:50:39 +0530 Subject: [PATCH 01/14] Create If-statement practice.m --- lesson5/If-statement practice.m | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lesson5/If-statement practice.m diff --git a/lesson5/If-statement practice.m b/lesson5/If-statement practice.m new file mode 100644 index 0000000..9c36e4e --- /dev/null +++ b/lesson5/If-statement practice.m @@ -0,0 +1,10 @@ +function out= picker(condition, in1, in2) +if condition + out= in1; +else + out= in2; + +end + +out = picker(true,1,2) +out = picker(false,1,2) From fb737c6289dccc10e264e63f2b5027c999a9ec8e Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:52:00 +0530 Subject: [PATCH 02/14] Create More practice.m --- lesson5/More practice.m | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lesson5/More practice.m diff --git a/lesson5/More practice.m b/lesson5/More practice.m new file mode 100644 index 0000000..79b23b8 --- /dev/null +++ b/lesson5/More practice.m @@ -0,0 +1,7 @@ +function admit= eligible(v,q) +if (((v+q)/2) >=92 && ((q>88) && (v>88))) + admit= true ; +else + admit = false; +end + From 4119efafdc3356441eb37e8c7d626e48dd09b7e6 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:52:52 +0530 Subject: [PATCH 03/14] Create nargin.m --- lesson5/nargin.m | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lesson5/nargin.m diff --git a/lesson5/nargin.m b/lesson5/nargin.m new file mode 100644 index 0000000..f031945 --- /dev/null +++ b/lesson5/nargin.m @@ -0,0 +1,6 @@ +function too_young = under_age (age,limit) +if nargin==1 + too_young= age<21; +else + too_young= age Date: Thu, 14 Oct 2021 12:54:04 +0530 Subject: [PATCH 04/14] Create Lesson 5 Wrap-up.m --- lesson5/Lesson 5 Wrap-up.m | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lesson5/Lesson 5 Wrap-up.m diff --git a/lesson5/Lesson 5 Wrap-up.m b/lesson5/Lesson 5 Wrap-up.m new file mode 100644 index 0000000..6447b75 --- /dev/null +++ b/lesson5/Lesson 5 Wrap-up.m @@ -0,0 +1,31 @@ +function isvalid = valid_date(y, m, d) + % Check if the inputs are valid + % Check that they are scalars + if ~(isscalar(y) && isscalar(m) && isscalar(d)) + isvalid = false; + % Check that inputs are positive + elseif ~all([y, m, d] > 0) + isvalid = false; + % Check that inputs are integers (not the data type) + elseif any(rem([y, m, d], 1)) + isvalid = false; + % Check that m and d are below the max possible + elseif (m > 12) || (d > 31) + isvalid = false; + % The inputs could be a valid date, let's see if they actually are + else + % Vector of the number of days for each month + daysInMonth = [31 28 31 30 31 30 31 31 30 31 30 31]; + % If leap year, change days in Feb + if isequal(rem(y, 4), 0) && (~isequal(rem(y, 100), 0) || isequal(rem(y, 400), 0)) + daysInMonth(2) = 29; + end + maxDay = daysInMonth(m); + if d > maxDay + isvalid = false; + else + isvalid = true; + end + + end +end From 643fed029b8e202730ed2ebf557cbda61be29a56 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:56:26 +0530 Subject: [PATCH 05/14] Create Built-in functions.m --- Lesson4/Built-in functions.m | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson4/Built-in functions.m diff --git a/Lesson4/Built-in functions.m b/Lesson4/Built-in functions.m new file mode 100644 index 0000000..03f561b --- /dev/null +++ b/Lesson4/Built-in functions.m @@ -0,0 +1,3 @@ +function [mmr,mmm] = minimax(M) +mmr=abs(max(M,[],2)-min(M,[],2))'; +mmm=(max(M,[],'all')-min(M,[],'all')); From c3cf0d3c67db5a0272aed3452ce27561e0c6c469 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:57:27 +0530 Subject: [PATCH 06/14] Create Lesson 4 Wrap-up.m --- Lesson4/Lesson 4 Wrap-up.m | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Lesson4/Lesson 4 Wrap-up.m diff --git a/Lesson4/Lesson 4 Wrap-up.m b/Lesson4/Lesson 4 Wrap-up.m new file mode 100644 index 0000000..4f87884 --- /dev/null +++ b/Lesson4/Lesson 4 Wrap-up.m @@ -0,0 +1,5 @@ +function T=trio(m,n) +a=ones(m,n); +b=2*ones(m,n); +c=3*ones(m,n); +T=[a;b;c] From e8026f3d09e62aa6e85a084052d1d85e4c87eb2d Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:59:50 +0530 Subject: [PATCH 07/14] Create A Simple Function.m --- Lesson3/A Simple Function.m | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson3/A Simple Function.m diff --git a/Lesson3/A Simple Function.m b/Lesson3/A Simple Function.m new file mode 100644 index 0000000..533016e --- /dev/null +++ b/Lesson3/A Simple Function.m @@ -0,0 +1,3 @@ +function a= tri_area(base,hight) +a=0.5*base*hight; +end From d2febf2ea3d33febd0124f489ec52e258b316e6e Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:00:33 +0530 Subject: [PATCH 08/14] Create Multiple Outputs.m --- Lesson3/Multiple Outputs.m | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Lesson3/Multiple Outputs.m diff --git a/Lesson3/Multiple Outputs.m b/Lesson3/Multiple Outputs.m new file mode 100644 index 0000000..0d614f7 --- /dev/null +++ b/Lesson3/Multiple Outputs.m @@ -0,0 +1,5 @@ +function [tl,tr,bl,br]= corners(ip) +tl=ip(1,1); +tr=ip(1,end); +bl=ip(end,1); +br=ip(end,end); From db92a555dd505105f386afb93eccbbbdf717106d Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:02:32 +0530 Subject: [PATCH 09/14] Create Lesson 3 Wrap-up.m --- Lesson3/Lesson 3 Wrap-up.m | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Lesson3/Lesson 3 Wrap-up.m diff --git a/Lesson3/Lesson 3 Wrap-up.m b/Lesson3/Lesson 3 Wrap-up.m new file mode 100644 index 0000000..01337f9 --- /dev/null +++ b/Lesson3/Lesson 3 Wrap-up.m @@ -0,0 +1,2 @@ +function fare= taxi_fare(dist_km,time_min) +fare=5+(2*(ceil(dist_km)-1))+(0.25*ceil(time_min)); From 75279207d5316bb91161ec8530feb9d7bf494131 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:23:32 +0530 Subject: [PATCH 10/14] Create Colon Operator.m --- Lesson2/Colon Operator.m | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Lesson2/Colon Operator.m diff --git a/Lesson2/Colon Operator.m b/Lesson2/Colon Operator.m new file mode 100644 index 0000000..a476b79 --- /dev/null +++ b/Lesson2/Colon Operator.m @@ -0,0 +1,2 @@ +odds=1:2:100 +evens=100:-2:1 From 94193bedadff3bf158430b5eb099c53be532b06a Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:24:11 +0530 Subject: [PATCH 11/14] Create Matrix Indexing.m --- Lesson2/Matrix Indexing.m | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson2/Matrix Indexing.m diff --git a/Lesson2/Matrix Indexing.m b/Lesson2/Matrix Indexing.m new file mode 100644 index 0000000..c083ca8 --- /dev/null +++ b/Lesson2/Matrix Indexing.m @@ -0,0 +1,3 @@ +A = [1:5; 6:10; 11:15; 16:20]; +v=A(:,2) +A(end,:)=0 From 38e0d9f4c29371d15a8166dec65efe744c7ac777 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:24:59 +0530 Subject: [PATCH 12/14] Create Matrix Arithmetic.m --- Lesson2/Matrix Arithmetic.m | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Lesson2/Matrix Arithmetic.m diff --git a/Lesson2/Matrix Arithmetic.m b/Lesson2/Matrix Arithmetic.m new file mode 100644 index 0000000..730ce2e --- /dev/null +++ b/Lesson2/Matrix Arithmetic.m @@ -0,0 +1,5 @@ +A = [1:5; 6:10; 11:15; 16:20]; + +b=[1 1 1 1] +c=[1;1;1;1;1] +result=b*A*c From a05ba5426a0654a2f0954b65c19f9b64e28a7b26 Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:26:37 +0530 Subject: [PATCH 13/14] Create MATLAB Calculation.m --- Lesson1/MATLAB Calculation.m | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Lesson1/MATLAB Calculation.m diff --git a/Lesson1/MATLAB Calculation.m b/Lesson1/MATLAB Calculation.m new file mode 100644 index 0000000..0630e29 --- /dev/null +++ b/Lesson1/MATLAB Calculation.m @@ -0,0 +1,7 @@ +borrowed = 1000 + +rate = 0.1 + +first_year_debt=borrowed*rate+borrowed + +debt=first_year_debt+first_year_debt*rate From b3a381125bbaf2b33a0a8289c076d495c9e8f04f Mon Sep 17 00:00:00 2001 From: Ganesh Savant <65601315+ganeshbs17@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:27:12 +0530 Subject: [PATCH 14/14] Create Lesson 1 Wrap-up.m --- Lesson1/Lesson 1 Wrap-up.m | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Lesson1/Lesson 1 Wrap-up.m diff --git a/Lesson1/Lesson 1 Wrap-up.m b/Lesson1/Lesson 1 Wrap-up.m new file mode 100644 index 0000000..a59e4da --- /dev/null +++ b/Lesson1/Lesson 1 Wrap-up.m @@ -0,0 +1,2 @@ +hundred=0.1/(9.58/(60*60)) +marathon=42.195/(2+(1/60)+(39/(60*60)))