Commit 798612c0 authored by KUDUMULA AAHWAN REDDY's avatar KUDUMULA AAHWAN REDDY

lab01_group24_final

parent 92f8905f
function R1 = backward_solve(A1)
m = size(A1,1);
n = size(A1,2);
c = m*n;
B = zeros(c,c);
for i = 1:c
for j= 1:c
k1=(i-1-mod(i-1,n))/n;
k2=(1+mod(i-1,n));
l1=(j-1-mod(j-1,n))/n;
l2=(1+mod(j-1,n));
if(((abs(k1-l1)==0)&&(abs(k2-l2)==1))||((abs(k1-l1)==1)&&(abs(k2-l2)==0)))
B(i,j) = 1;
end
if((k1==l1)&&(k2==l2))
B(i,j) = 1;
end
end
end
R = zeros(1,c);
A = zeros(1,c);
for i = 1:m
for j=1:n
A(1,(((i-1)*n)+j)) = A1(i,j);
end
end
R = (A*(B^(-1))).*det(B);
R = abs(R);
R = int64(R);
R = mod(R,2);
R1 = zeros(m,n);
for i = 1:m
for j=1:n
R1(i,j) = R(1,(((i-1)*n)+j));
end
end
return
endfunction
function R1 = backward_solve_3(A1)
L = [1 1 0; 1 1 1; 0 1 1 ];
M = [1 0 0; 0 1 0; 0 0 1 ];
N = zeros(3,3);
B = [L M N; M L M; N M L ];
A = [A1(1, :) A1(2, :) A1(3, :)];
R = zeros(1,9);
X = [0 0 1 1 0 1 0 1 1 ];
%R = mod(A + X*B,2);
%R = A/B;
%R = (A + X*B);
R = (A*(B^(-1))).*det(B);
R = abs(R);
R = int64(R);
R = mod(R,2);
R1 = zeros(3,3);
R1 = [R(1,1:3); R(1,4:6); R(1,7:9)];
return
endfunction
%disp(A)
%disp(B)
\ No newline at end of file
180.0 100 0.05 5 3.5
\ No newline at end of file
0.0 0.0 76.63 27 0.027 0.0555 7 5 3.5 5
\ No newline at end of file
clear; clc;
file1 = fopen('input_outlab_task_A1.txt');
A = fscanf(file1, '%f', [5,1]);
fclose(file1);
f = @ (a) (((A(2)-A(4))*tan(a)) + (A(4)*sin(a))/(sqrt((A(5))^2-((sin(a))^2))) - A(1));
theta = fzero(f,[0,1.5]);
theta = theta * (180/pi);
file2 = fopen('output_outlab_task_A1.txt','w');
fprintf(file2, '%f', theta);
fclose(file2);
\ No newline at end of file
clear; clc;
file1 = fopen('input_outlab_task_A2.txt');
A = fscanf(file1, '%f', [10,1]);
fclose(file1);
x1 = A(3) - A(1);
y1 = A(4) - A(2);
%secr = A(9)/((sqrt((A(9))^2-((sin(a))^2))));
%a1 = (((sec(a))*(y1-A(8))) + ((A(9)/((sqrt((A(9))^2-((sin(a))^2)))))*(A(8))) + ((sec(a))*(A(5))*(A(10))))/(A(6)-(A(5)*(sec(a))));
f = @ (a) ((A(5)*(A(10)+ ( ( ((sec(a))*(y1-A(8))) + (((A(9)/((sqrt((A(9))^2-((sin(a))^2)))))*(A(8)))*A(9)) + ((sec(a))*(A(5))*(A(10))) ) / (A(6)-(A(5)*(sec(a)))) ) )*tan(a)) + ((y1-A(8))*tan(a)) + ((A(8)*sin(a))/(sqrt((A(9))^2-((sin(a))^2)))) - x1) ;
theta = fzero(f,[0.1,1.0]);
A(10) = 3*A(10);
a3 = (((sec(theta))*(y1-A(8))) + (((A(9)/((sqrt((A(9))^2-((sin(theta))^2)))))*(A(8)))*A(9)) + ((sec(theta))*(A(5))*(A(10))))/(A(6)-(A(5)*(sec(theta))));
xf = x1;
yf = y1 + (3*A(10)+a3)*A(5);
theta = theta * (180/pi);
%disp(theta)
%disp(yf)
file2 = fopen('output_outlab_task_A2.txt','w');
fprintf(file2, '%f %f %f', theta, xf, yf);
fclose(file2);
\ No newline at end of file
62.003645
\ No newline at end of file
41.070190 76.630000 93.409613
\ No newline at end of file
GROUP NUMBER - 24
(150050071, Aahwan), (150050072, Sai Teja), (150050079, Rathod Dinesh).
150050071- 100%
150050072- 100%
150050079- 100%
Comments on the code :
-Task A2 had an important point. The consideration that laser travels with a velocity equal to velocity/refractiveIndex in the medium.
-There was a bit of an ambiguity in the task A2 description.Strictly considering the meaning, actually the second angle must be taken(because it is mentioned: to destroy the shield and it takes 2 hits to destroy it). But since the answer given is the angle for the first laser beam, the code for the same has been written.
-An interesting pattern was observed for the action matrix for the general case of backward solve but that wasn't implemented because of the ease of generation using loops was more.
Honour code :
We pledge on our honour that we have not given or received any unauthorized assistance on this assignment or any previous task.
-(150050071, Aahwan), (150050072, Sai Teja), (150050079, Rathod Dinesh).
Citations :
Octave learnt and understood from :
https://www.youtube.com/watch?v=gkVOSxmhtyk&index=17&list=PLHj4uM4X8Oso_M2yN6Fg0_Mp219z6f5-W
Reflection essay :
In the lights out problem found a pattern for the action matrix for different m*n matrices.
Solved the interesting problem of two spaceships.
Realised the point that laser travels with a velocity equal to velocity/refractive index in the medium!(that eureka moment :))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment