![]() |
||||||
|
| Script S1_2_2.m | |||
|
|||
|
%==============================================
%A simple convex mirror %The function fmirror is required %============================================== % %============================================== %%distances zp of point images from the vertex %of a convex mirror in mm %and corresponding transverse magnifications mt %are found and plotted %============================================== % %the value of focal length in mm f=15; %the array of distances, in mm, of point objects from the mirror zz=-30:1:30; %the size of the array zz max=length(zz); %the arrays zp and mt are calculated using the function fmirror for i=1:max k(i)=i; z=zz(i); A=fmirror(f,z); zp(i)=A(1); mt(i)=A(2); end % %an array of max rows and four columns, called matr, is constructed %the MATLAB transpose operator (') change a row of element %in a column matr=[k' zz' zp' mt'] % %the subplot command is used subplot(2,1,1) plot(zz,zp,'r*-'),grid on,title('point images distances function of point objects distances') axis([-30 30 -100 100]) subplot(2,1,2) plot(zz,mt,'b*-'),grid on,title('transverse magnifications function of the point objects distances') axis([-30 30 -5 5]) %=================================================== % |
|||
| Top | |||
| Function fmirror.m | |||
|
|||
|
%===================================================================
%If the focal length f and the distance z of a point object are known %the function determines the distance zp of the image %and the transverse magnification %this function is necessary to run %1.2.1 A simple concave mirror %1.2.2 A simple convex mirror %=================================================================== % function F=fmirror(f,z) a=f*z; b=z-f; %if z=-f we put zp=300; %if z is not equal to -f if b~=0 % we put zp=a/b; end %z is equal to zero we put mt=1; %if z is not equal to zero if z~=0 %standard rule is used mt=-zp/z; end %ris contains the two values calculated ris=[zp,mt]; %the values of the array ris are conveyed to F F=ris; %============================================== % |
|||
| Top | |||