![]() |
| Script Image_size.m | |||
|
|||
|
%unit of measurement
unitScreen=get(0,'units') %the size of the screen array is read screen=get(0,'ScreenSize') % the width of the screen is assigned to Sx Sx=screen(3) % the height of the screen is assigned to Sy Sy=screen(4) %% %======================================================== %A PLOT IS DEFINED WITH POSITION AND SIZE FIXED BY MATLAB %======================================================== x=imread('owl.png'); image(x); axis off; set(gcf,'Menubar','none','Toolbar','none') set(gca,'position',[0,0,1,1]) unitFP=get(gcf,'units') pos=get(gcf,'position') % unitFI=get(gcf,'units') %the width of the Figure is assigned to Pc %(the number of pixels columns) Pc=pos(3) %the height of the Figure is assigned to Pr %(the number of pixels rows) Pr=pos(4) %the ratio between Pc and Pr R=Pc/Pr %% %========================================================== %A NEW POSITION WITH A SMALLER SIZE OF THE FIGURE AND IMAGE %========================================================== % %the distance of the left side of the figure %from the left side of the screen dx1=670; %the distance of the bottom side of the figure %from the bottom side of the screen dy1=100; % %the desired height of the Figure is assigned H1=250; % %the width consistent with Pr and Pc is calculated W1=R*H1; %the new position and size are assigned %with the figure command figure('Position',[dx1 dy1 W1 H1]) image(x); axis off; set(gcf,'Menubar','none','Toolbar','none') % set(gca,'position',[0.25,0.25,0.5,0.5]) set(gca,'position',[0,0,1,1]) % set(gcf,'Menubar','none','Toolbar','none') %new position and size are given in the Command Window get(gcf,'position') % %% %========================================================== %A NEW POSITION WITH A GREATER SIZE OF THE FIGURE AND IMAGE %========================================================== % %%the distance of the left side of the figure %from the left side of the screen % dx2=30; dx2=1; %the distance of the bottom side of the figure %from the bottom side of the screen % dy2=30; dy2=1; % %the desired height of the Figure is assigned H2=490; % %the width consistent with Pr and Pc is calculated W2=R*H2; %the new position and size are assigned %with the figure command figure('Position',[dx2 dy2 W2 H2]) %the greater figure of the plot is read % x=imread('owl.png'); image(x); axis off; set(gcf,'Menubar','none','Toolbar','none') % set(gca,'position',[0.25,0.25,0.5,0.5]) set(gca,'position',[0,0,1,1]) set(gcf,'Menubar','none','Toolbar','none') %new position and size are given in the Command Window get(gcf,'position') |
|||
| Back | |||