Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs251_group09
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
HIMANSHU GUPTA
cs251_group09
Commits
722fcd2a
Commit
722fcd2a
authored
Aug 24, 2016
by
HIMANSHU GUPTA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add lab1
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
lab1/refraction.m
lab1/refraction.m
+34
-0
No files found.
lab1/refraction.m
0 → 100644
View file @
722fcd2a
# Code gives error if no solution in [0,pi/2] exits for given nx,ny.
function y = refraction(i) #defining the function whose roots are to be found
a = load('input_inlab_task_A1.txt'); #taking input from file
nx = a(1);
ny = a(2);
y = sin(i) - (nx*cos(i) + ny*sin(i))*sin(i/3); #function
endfunction
left =0.0001;
#find left,right by iteration
if refraction(pi/2) >0
for n=[0.0001:0.001:pi/2]
if refraction(n)
<0
left =
n;
break
;
end
end
end
if
refraction
(
pi
/
2
)
<
0
for
n=
[0.0001:0.001:pi/2]
if
refraction
(
n
)
>
0
left = n;
break;
end
end
end
right = pi/2+0.00001; #defined range for i solution
x0 = [left right];
[i,info] = fzero("refraction", x0); #solving the function in given range
fid = fopen ("output_inlab_task_01.txt", "w"); #writing to text file
fdisp (fid,i);
fclose (fid);
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