Figure of screen size

309 views (last 30 days)
Noaman Ahmad
Noaman Ahmad on 3 Dec 2014
Answered: Steven Lord on 18 Sep 2018
How can I get the figure window of exactly the same size as that of my screen? Also how can I draw axis on this full figure window? Please help! Any help will be highly appreciated!

Accepted Answer

Adam on 3 Dec 2014
Edited: Adam on 4 Dec 2014
If you are in R2014b you can get screensize programatically as:
screensize = get( groot, 'Screensize' );
In previous versions if I remember correctly it would be:
screensize = get( 0, 'Screensize' );
may also help for advise on maximising a figure programatically.
Adam on 18 Sep 2018
I've never used Simulink so I don't know what is valid there I'm afraid.

Sign in to comment.

More Answers (4)

Rini Varghese
Rini Varghese on 7 Sep 2017
Edited: Rini Varghese on 7 Sep 2017
One solution to bypass the problem of being connected to different screens that might have different resolution (screen sizes), is to use the following:
figure('units','normalized','outerposition',[0 0 1 1])
This way the outer position of the figure window is normalized to whatever screen is used. Found this solution from an older post here:

Marco Castelli
Marco Castelli on 3 Dec 2014
If your screen has for example the resolution 1920x1080:
fig1 = figure;
pos_fig1 = [0 0 1920 1080];
In the pos_fig1 vector the first and the second values are coordinates x and y of the lower left corner, the other two numbers are the length and the depth

Philip janiszewski
Philip janiszewski on 31 Jan 2017
% >>>>>>>>>>>>>>>>>>>>>>>>>> PLOT THE RESULTS <<<<<<<<<<<<<<<<<<<<<<<<<<< si=figure
% ---------- Output, Prediction and Prediction error ---------- for ii=1:outputs, figure(si+ii) subplot(211) plot(Y(ii,:),'b-'); hold on plot(Yhat(ii,:),'r--');hold off xlabel('time (samples)') if outputs==1, title('Output (solid) and one-step ahead prediction (dashed)') else title(['Output (solid) and one-step ahead prediction (dashed) (output # ' ... num2str(ii) ')']); end grid
title('Prediction error (y-yhat)')
xlabel('time (samples)')
% --------- Correlation functions ---------- for ii=1:outputs, figure(si+outputs+ii) subplot(nu+1,1,1); M=min(25,N-1); Eauto=crossco(E(ii,:),E(ii,:),M); Eauto=Eauto(M+1:2*M+1); conf=1.96/sqrt(N); plot([0:M],Eauto(1:M+1),'b-'); hold on plot([0 M],[conf -conf;conf -conf],'r--');hold off set(gca,'xlim',[0 M]); xlabel('lag') if outputs==1 title('Auto-correlation function of prediction error') else title(['Autocorrelation coefficients for prediction error (output # ' ... num2str(ii) ')']); end grid
for i=1:nu,
plot([-M:M], UEcross,'b-'); hold on
plot([-M M],[conf -conf;conf -conf],'r--');hold off
title(['Cross-correlation coef. of u' num2str(i) ' and prediction error'])
axis([-M M -ymax ymax]);
% ---------- Extract linear model from network ---------- dy2dx=zeros(outputs*(inputs+1),N);
% Matrix with partial derivative of each output with respect to each of the % outputs from the hidden neurons for t=1:N, dy2dy1 = W2(:,1:hidden); for j = H_output', dy2dy1(j,:) = W2(j,1:hidden)*(1-Yhat(j,t).*Yhat(j,t)); end
% Matrix with partial derivatives of the output from each hidden neurons with
% respect to each input:
dy1dx = W1;
for j = H_hidden',
dy1dx(j,:) = W1(j,:)*(1-y1(j,t).*y1(j,t));
% Matrix with partial derivative of each output with respect to each input
dl = (dy2dy1 * dy1dx)';
dy2dx(:,t) = dl(:);
figure(si+2*outputs+1) subplot(212) plot(dy2dx(1:outputs*inputs,:)') title('Linearized network parameters') xlabel('time (samples)') grid for ii=1:outputs, subplot(2,outputs,ii); hist(E(ii,:),20) end subplot(2,outputs,1); title('Histogram of prediction errors') subplot(111) figure(si+1);
ad the programs stops and shows
Undefined operator '+' for input arguments of type 'matlab.ui.Figure'.
Error in nnvalid (line 249) figure(si+ii)
Error in ModelScaled (line 115) [Yhat,NSSE]=nnvalid(Model,NetDef,NN,w1,w2,Yv(:,Nr)',Uv');
but on earlier version i.e. R2013 it works proprly . What to do ?
  1 Comment
Steven Lord
Steven Lord on 31 Jan 2017
1. This isn't related to this original question, so you should have created a new post for it.
2. As noted in the documentation for the major graphics changes introduced in release R2014b, "Graphics Handles Are Now Objects, Not Doubles". Don't try to do arithmetic on graphics objects. If you must try to create figures with sequential numbers, that will still work, but adding a figure object and a number won't.

Sign in to comment.

Steven Lord
Steven Lord on 18 Sep 2018
If you're using release R2018a or later, use the WindowState property of figure objects. See the description of this property on the Figure Properties page for information about the allowed values.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!