filename = "input_outlab_task_A1.txt";
[x1,y1,d,w,n] = textread(filename,"%f %f %f %f %f"); #reading data from input file
f = @(x) [(y1-w)*tand(x(1)) + w*tand(x(2)) - x1;n*sind(x(2)) - sind(x(1))];
x = fsolve(f,[0;0]); # using fsolve to find the required values
csvwrite("output_outlab_task_A1.txt",x(1)); #writing the calculated answer in the output file