Adding refraction.m file from inlab01 task A1

parent 77ec6e4d
x = linspace(0,pi/2,100); % x stores reflection angle(i)
function y = f(x) % by Snells' Law, we could conclude that solution of this equation is the required answer
data = load("input_inlab_task_A1.txt");
nx = data(1);
ny = data(2);
y = sin(x)-(nx*cos(x)+ny*sin(x)).*sin(x/3);
fun = @f;
x0 = [0.0001 pi/2];
z = fzero(fun,x0); % stores the root of f closest to x0 in z
out = fopen("output inlab task 01.txt",'w');
fdisp(out,z); % writes ans in output file
\ 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