f=@(x)((tan(x)*(y1-d-w))+(w*(sin(x)/sqrt((n*n)-(sin(x)*sin(x)))))+(tan(x)*(d+(v2*(((((v2*t1)+y1-w)/(cos(x)*vl))+((w*n*n)/sqrt((n*n)-(sin(x)*sin(x)))*vl))/(1-(v2/(cos(x)*vl)))+t1))))-x1);%function made after doing the calculation
l=fsolve(f,0.1);%returns in radians
t=((((v2*t1)+y1-w)/(cos(l)*vl))+((w*n*n)/sqrt((n*n)-(sin(l)*sin(l)))*vl))/(1-(v2/(cos(l)*vl)));%calculates total time taken to hit the shields
m=(l*180.0)/pi;%returns in degrees
g=x1;%assigning g
y=y1+(v2*(t+t1));%returns the final y coordinate of the X1 plane
a=[mgy];
csvwrite("output_outlab_task_A2.txt",a);%prints the output in the given file
I pledge on my honour that i have not given or received any unauthorised assistance on this assignment or any previous task.
We learnt algorithms for the lights out problem,efficient use of fsolve and other functions of octave very much similar to matlab.Coding for long hours without any breaks.