I need to find rp for each x but I’m having a hard time because matlab gives me this error
Error in enee_408e_hw2_pb1 (line 6)
rp=(z2*cos(t2)-z1*cos(x))/(z2*cos(t2)+z1*cos(x))
here is my code
x=0:.01:pi/2;
n2=1.7;
t2=asin(sin(x)/n2);
z1=377*cos(x);
z2=377\cos(x);
rp=(z2*cos(t2)-z1*cos(x))/(z2*cos(t2)+z1*cos(x));
I want to calculate rp for each angle from 0 to pi/2 and then plot it. What am I doing wrong?
Every operation is perform on same cell in z1 and z2. Matlab/Ocatave calculate enquation based on variable’s type. So if you put
*between vectors it try to calculate cross product. Probably problem was\, I have no idea what Matlab tried to do with it. Adding.before operator change approach to more natural (for non mathematical folks) and multiply corresponding cells.But still I’m not sure it this is what you expected