Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs251_group31
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CHITWAN SAHARIA
cs251_group31
Commits
528f7706
Commit
528f7706
authored
8 years ago
by
CHITWAN SAHARIA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Lab 01"
This reverts commit
3dc00951
.
parent
3dc00951
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
257 deletions
+0
-257
lab01_group31_final/backward_solve.m
lab01_group31_final/backward_solve.m
+0
-56
lab01_group31_final/backward_solve_3.m
lab01_group31_final/backward_solve_3.m
+0
-50
lab01_group31_final/main_task_A1.m
lab01_group31_final/main_task_A1.m
+0
-23
lab01_group31_final/main_task_A2.m
lab01_group31_final/main_task_A2.m
+0
-44
lab01_group31_final/main_task_A3.m
lab01_group31_final/main_task_A3.m
+0
-65
lab01_group31_final/readme.txt
lab01_group31_final/readme.txt
+0
-19
No files found.
lab01_group31_final/backward_solve.m
deleted
100644 → 0
View file @
3dc00951
function
B
=
backward_solve
(
initial
)
col
=
columns
(
initial
);
row
=
rows
(
initial
);
col1
=
col
*
row
;
A
=
zeros
(
col1
,
col1
);
for
a
=
1
:
row
for
aa
=
1
:
col
A
((
a
-
1
)
*
col
+
aa
,(
a
-
1
)
*
col
+
aa
)
=
1
;
if
(
a
>
1
)
A
((
a
-
1
)
*
col
+
aa
,(
a
-
1
)
*
col
+
aa
-
col
)
=
1
;
endif
if
(
a
<
row
)
A
((
a
-
1
)
*
col
+
aa
,(
a
-
1
)
*
col
+
aa
+
col
)
=
1
;
endif
if
(
aa
>
1
)
A
(((
a
-
1
)
*
col
+
aa
),((
a
-
1
)
*
col
+
aa
-
1
))
=
1
;
endif
if
(
aa
<
col
)
A
((
a
-
1
)
*
col
+
aa
,(
a
-
1
)
*
col
+
aa
+
1
)
=
1
;
endif
endfor
endfor
b
=
zeros
(
col1
,
1
);
for
a
=
1
:
row
for
aa
=
1
:
col
b
((
a
-
1
)
*
col
+
aa
,
1
)
=
initial
(
a
,
aa
);
endfor
endfor
m
=
1
;
while
(
m
<=
col1
)
% on mth column
temp1
=
m
;
while
(
A
(
temp1
,
m
)
==
0
)
temp1
=
temp1
+
1
;
endwhile
if
(
temp1
!
=
m
)
A
([
temp1
m
],:)
=
A
([
m
temp1
],:);
b
([
temp1
m
],:)
=
b
([
m
temp1
],:);
endif
n
=
1
;
while
(
n
<=
col1
)
if
(
A
(
n
,
m
)
==
1
&&
n
!
=
m
)
A
(
n
,:)
=
mod
(
A
(
n
,:)
+
A
(
m
,:),
2
);
b
(
n
,
1
)
=
mod
(
b
(
n
,
1
)
+
b
(
m
,
1
),
2
);
endif
n
=
n
+
1
;
endwhile
m
=
m
+
1
;
endwhile
B
=
zeros
(
row
,
col
);
for
a
=
1
:
row
for
aa
=
1
:
col
B
(
a
,
aa
)
=
b
((
a
-
1
)
*
col
+
aa
,
1
);
endfor
endfor
endfunction
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab01_group31_final/backward_solve_3.m
deleted
100644 → 0
View file @
3dc00951
function
B
=
backward_solve_3
(
initial
)
A
=
[
[
1
1
0
1
0
0
0
0
0
];
[
1
1
1
0
1
0
0
0
0
];
[
0
1
1
0
0
1
0
0
0
];
[
1
0
0
1
1
0
1
0
0
];
[
0
1
0
1
1
1
0
1
0
];
[
0
0
1
0
1
1
0
0
1
];
[
0
0
0
1
0
0
1
1
0
];
[
0
0
0
0
1
0
1
1
1
];
[
0
0
0
0
0
1
0
1
1
]
];
b
=
[
[
initial
(
1
,
1
)];
[
initial
(
1
,
2
)];
[
initial
(
1
,
3
)];
[
initial
(
2
,
1
)];
[
initial
(
2
,
2
)];
[
initial
(
2
,
3
)];
[
initial
(
3
,
1
)];
[
initial
(
3
,
2
)];
[
initial
(
3
,
3
)]
];
m
=
1
;
while
(
m
<
10
)
% on mth column
temp1
=
m
;
while
(
A
(
temp1
,
m
)
==
0
)
temp1
=
temp1
+
1
;
endwhile
if
(
temp1
!
=
m
)
A
([
temp1
m
],:)
=
A
([
m
temp1
],:);
b
([
temp1
m
],:)
=
b
([
m
temp1
],:);
endif
n
=
1
;
while
(
n
<
10
)
if
(
A
(
n
,
m
)
==
1
&&
n
!
=
m
)
A
(
n
,:)
=
mod
(
A
(
n
,:)
+
A
(
m
,:),
2
);
b
(
n
,
1
)
=
mod
(
b
(
n
,
1
)
+
b
(
m
,
1
),
2
);
endif
n
=
n
+
1
;
endwhile
m
=
m
+
1
;
endwhile
B
=
[
[
b
(
1
,
1
)
b
(
2
,
1
)
b
(
3
,
1
)];
[
b
(
4
,
1
)
b
(
5
,
1
)
b
(
6
,
1
)];
[
b
(
7
,
1
)
b
(
8
,
1
)
b
(
9
,
1
)];
];
endfunction
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab01_group31_final/main_task_A1.m
deleted
100644 → 0
View file @
3dc00951
DATA = load("-ascii", "input_outlab_task_A1.txt");
global y1 = DATA(1,2);
global x1 = DATA(1,1);
global d = DATA(1,3);
global w = DATA(1,4);
global n = DATA(1,5);
function retval = main_task_A1(p)
global y1;
global x1;
global d;
global w;
global n;
angle1 = tan(p);
angle2 = tan(asin(sin(p)/n));
retval = x1-w*angle2-(y1-w)*angle1;
endfunction
[x,fval,info] = fsolve(@main_task_A1,0.8);
x = x * 180/pi;
fid = fopen("output_outlab_task_A1.txt","w");
fdisp(fid,sprintf('%.1f', x));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab01_group31_final/main_task_A2.m
deleted
100644 → 0
View file @
3dc00951
DATA = load("-ascii", "input_outlab_task_A2.txt");
global xt = DATA(1,1);
global yt = DATA(1,2);
global xw = DATA(1,3) - xt;
global yw = DATA(1,4) - yt;
global v2 = DATA(1,5);
global vl = DATA(1,6);
global d = DATA(1,7);
global w = DATA(1,8);
global n = DATA(1,9);
global t1 = DATA(1,10);
function retval = main_task_A2(a)
global xt;
global yt;
global xw;
global yw;
global v2;
global vl;
global d;
global w;
global n;
global t1;
tanb = tan(asin(sin(a)/n));
t = (xw - w*tanb)/(vl*sin(a)) + (n*n*w*tanb)/(vl*sin(a));
vlcosa = vl*cos(a);
vlcosb = vl*cos(asin(sin(a)/n));
retval = w*n/(vlcosb) + (yw-d-w)/(vlcosa) + (d+v2*(t+t1))/(vlcosa) - t;
endfunction
[x, fval, info] = fsolve(@main_task_A2, 0.8);
tanb = tan(asin(sin(x)/n));
t = (xw - w*tanb)/(vl*sin(x)) + (n*n*w*tanb)/(vl*sin(x));
x = x*180/pi;
xf = xw;
yf = yw + v2*(t1+t);
fid = fopen("output_outlab_task_A2.txt","w");
fdisp(fid,sprintf('%.1f %.1f %.1f', x, xf, yf));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab01_group31_final/main_task_A3.m
deleted
100644 → 0
View file @
3dc00951
DATA
=
load
(
"-ascii"
,
"input_outlab_task_A3.txt"
);
global
xt
=
DATA
(
1
,
1
);
global
yt
=
DATA
(
1
,
2
);
global
xw
=
DATA
(
1
,
3
);
global
yw
=
DATA
(
1
,
4
);
global
vt
=
DATA
(
1
,
5
);
global
vw
=
DATA
(
1
,
6
);
global
vl
=
DATA
(
1
,
7
);
global
d
=
DATA
(
1
,
8
);
global
w
=
DATA
(
1
,
9
);
global
n
=
DATA
(
1
,
10
);
global
t1
=
DATA
(
1
,
11
);
global
xc
=
DATA
(
1
,
12
);
global
yc
=
DATA
(
1
,
13
);
function
retval
=
main_task_A3
(
a
)
global
xt
;
global
yt
;
global
xw
;
global
yw
;
global
vt
;
global
vw
;
global
vl
;
global
d
;
global
w
;
global
n
;
global
t1
;
global
xc
;
global
yc
;
r
=
sqrt
((
xc
-
xt
)
*
(
xc
-
xt
)
+
(
yc
-
yt
)
*
(
yc
-
yt
));
h
=
vt
*
t1
/
r
;
xt
=
xc
-
r
*
cos
(
h
);
yt
=
-
r
*
sin
(
h
);
xw
=
xw
-
xt
;
yw
=
yw
-
yt
;
vl
=
fsolve
(
@
val
,
1.0
);
vlsina
=
vl
*
sin
(
a
);
vlcosa
=
vl
*
cos
(
a
);
vl
=
sqrt
(
vlsina
*
vlsina
+
vlcosa
*
vlcosa
);
vlcosb
=
vl
*
cos
(
asin
(
sin
(
a
)/
n
));
tanb
=
tan
(
asin
(
sin
(
a
)/
n
));
t
=
(
xw
-
w
*
tanb
)/(
vlsina
)
+
(
n
*
n
*
w
*
tanb
)/(
vlsina
);
retval
=
w
*
n
/(
vlcosb
)
+
(
yw
-
yt
+
vw
*
(
t
+
t1
))/(
vlcosa
)
-
t
;
endfunction
function
retval
=
vlf
(
v
)
retval
=
v
*
v
+
vt
*
vt
+
2
*
v
*
vt
*
cos
(
h
+
a
)
-
vl
*
vl
;
endfunction
[
x
,
fval
,
info
]
=
fslove
(
@
main_task_A3
,
0.68
);
% tanb = tan(asin(sin(x)/n));
% t = (xw - w*tanb)/(vl*sin(x)) + (n*n*w*tanb)/(vl*sin(x));
x
=
x
*
180
/
pi
;
% xf = xw;
% yf = yw + vw*(t1+t);
% fid = fopen("output_outlab_task_A3.txt","w");
disp
(
sprintf
(
'%.1f %.1f'
,
x
,
fval
));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lab01_group31_final/readme.txt
deleted
100644 → 0
View file @
3dc00951
Group No. 31
(Chitwan Saharia,150050011)(100%)
(Sheshansh Agrawal,150050027)(100%)
(Abhinav Goyal,150050108)(100%)
I pledge on my honour that I have not given or received any
unauthorized assistance on this assignment or any previous task.
Citations:
1.https://www.gnu.org/software/octave/doc/v4.0.1/Defining-Functions.html
2.http://www.ueda.info.waseda.ac.jp/~n-kato/lightsout/
3.https://www.gnu.org/software/octave/doc/v4.0.0/Simple-File-I_002fO.html
4.http://www.mathportal.org/linear-algebra/matrices/gauss-jordan.php
Reflection:
1.Syntax of loops,functions and other things in Octave.
2.Handling Matrices in Octave.
3.Using If..Else and Switch Cases in Octave.
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment