Figure of screen size
173 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
Adam
2014-12-3
编辑:Adam
2014-12-4
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 个评论
Bhavanithya Thiraviaraja
2018-9-18
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?
更多回答(4 个)
Rini Varghese
2017-9-7
编辑:Rini Varghese
2017-9-7
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
0 个评论
Marco Castelli
2014-12-3
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
0 个评论
Philip janiszewski
2017-1-31
% >>>>>>>>>>>>>>>>>>>>>>>>>> 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 个评论
Steven Lord
2017-1-31
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.
Steven Lord
2018-9-18
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!