Commit 80d54442 authored by VINAYAK K's avatar VINAYAK K


Group 33 : Lab01_inlab
Group Members:
(Vinayak K, 150050098), (Shriram S B, 150050099), (Anubhaw Kuntal Xess, 150050100)
Vinayak K - 100%
Shriram S B - 100%
Anubhaw Kuntal Xess - 100%
I pledge on my honour that I have not given or received any unauthorized assistance on this assignment or any previous task.
Reflection essay:
- octave function declaration, global variables
- tried fsolve()
- found that fzero() better for single variable
- File I/O in octave
Citations: Gnu octave Documentation
\ No newline at end of file
% nx, ny global variable to hold tensor values
global nx;
global ny;
% reading nx, ny from input file
input_ptr = fopen("input_inlab_task_A1.txt", "r");
[nx, ny, count, errmsg] = fscanf(input_ptr, "%lf %lf", "C");
% function which returns value of the expression for some incident angle x(rad)
function ret_val = f (x)
global nx;
global ny;
ret_val = ( sin(x) / sin(x/3) - nx * cos(x) - ny * sin(x) );
% finding interval in which function changes sign
a = 1e-10;
dx = 0.1 + 1e-10;
b = dx;
while (f(a)*f(b) >= 0)
a += dx;
b += dx;
% the interval in which expression has a root
bracket = [a; b];
% fzero to find value at which expression is zero
[x, fval, info, output] = fzero("f", bracket);
output_ptr = fopen("output_inlab_task_01.txt", "w");
fprintf(output_ptr, "%f", x);
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