Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs251_group18
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
group18
cs251_group18
Commits
04feffe6
Commit
04feffe6
authored
Aug 24, 2016
by
SHRADDHEYA SHENDRE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding refraction.m (from lab01)
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
refraction.m
refraction.m
+25
-0
No files found.
refraction.m
0 → 100644
View file @
04feffe6
fileID
=
fopen
(
'input_inlab_task_A1.txt'
,
'r'
);
% Opening input file
formatSpec
=
'%f'
;
% format for dealing with floating point numbers, precision is better than 10^(-4)
A
=
fscanf
(
fileID
,
formatSpec
);
% Taking input from file and storing it in a Column Matrix/Array A
nx
=
A
(
1
);
% Indices start from 1 and not 0
ny
=
A
(
2
);
fun
=
@
(
x
)
(
nx
*
cos
(
x
)
*
sin
(
x
/
3
)
+
ny
*
sin
(
x
)
*
sin
(
x
/
3
)
-
sin
(
x
))
;
% Storing the Equation to Solve in fun
x0
=
1.6
;
% slightly larger than pi/2 -- > Initial Guess, Loose PreCondition : At least one root lies in (0, pi/2)
z
=
fsolve
(
fun
,
x0
);
% Using fsolve to compute the root and storing it in variable z
file_id
=
fopen
(
'output_inlab_task_01.txt'
,
'w'
);
% opening output File
fprintf
(
file_id
,
formatSpec
,
z
);
% "Loading" the value of z in Output File
fclose
(
file_id
);
% Closing output File -- > Important, without this code doesnt work
% First We tried : z = fzero(fun,x0)
\ No newline at end of file
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