Figure of screen size

199 visualizzazioni (ultimi 30 giorni)
Noaman Ahmad
Noaman Ahmad il 3 Dic 2014
Risposto: Steven Lord il 18 Set 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!

Risposta accettata

Adam
Adam il 3 Dic 2014
Modificato: Adam il 4 Dic 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.
  2 Commenti
Bhavanithya Thiraviaraja
Bhavanithya Thiraviaraja il 18 Set 2018
When I use this in a MATLAB function block inside a Simulink model, I get a coder error saying
"Property 'ScreenSize' is not recognized as valid."
How to solve this? Is there any other way?
Adam
Adam il 18 Set 2018
I've never used Simulink so I don't know what is valid there I'm afraid.

Accedi per commentare.

Più risposte (4)

Rini Varghese
Rini Varghese il 7 Set 2017
Modificato: Rini Varghese il 7 Set 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: https://www.mathworks.com/matlabcentral/answers/102219-how-do-i-make-a-figure-full-screen-programmatically-in-matlab

Marco Castelli
Marco Castelli il 3 Dic 2014
If your screen has for example the resolution 1920x1080:
fig1 = figure;
pos_fig1 = [0 0 1920 1080];
set(fig1,'Position',pos_fig1)
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 il 31 Gen 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
subplot(212)
plot(E(ii,:));
title('Prediction error (y-yhat)')
xlabel('time (samples)')
grid
subplot(111)
drawnow
end
% --------- 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,
subplot(nu+1,1,i+1);
UEcross=crossco(E(ii,:),U(i,1:N),M);
plot([-M:M], UEcross,'b-'); hold on
plot([-M M],[conf -conf;conf -conf],'r--');hold off
xlabel('lag')
title(['Cross-correlation coef. of u' num2str(i) ' and prediction error'])
ymax=min(5*conf,max([abs(UEcross)]));
axis([-M M -ymax ymax]);
grid
end
subplot(111)
drawnow
end
% ---------- 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));
end
% Matrix with partial derivative of each output with respect to each input
dl = (dy2dy1 * dy1dx)';
dl(inputs+1,:)=dl(inputs+1,:)+W2(:,hidden+1)';
dy2dx(:,t) = dl(:);
end
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 Commento
Steven Lord
Steven Lord il 31 Gen 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.

Accedi per commentare.


Steven Lord
Steven Lord il 18 Set 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.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by