Making Paper Position Variable depending on Machine

3 次查看(过去 30 天)
I have found an issue with generating plot pdfs where the the smae script used on different computers requires different alignement parameters inorder to fit the plots on one A4 sheet
I have created a prompt box to ask which machine is being used and it selects the variable but it does not insert it into the code
**********************************************************
%% Laptop or Workstation Analysis
orientation={ '[0.05, 0.1, 12, 8]' '[0.1, 0.1,30, 20]'};% These are the plot size parameters
prompt= ' Plese Select Computer'; 'Workstation = 1'; 'Laptop = 2';
name = ' Select Computer Type';
option = str2double(inputdlg(prompt,name,2,{'1'}));
if option >= 1 && option <= 2
O = orientation{option};
end
********************************************************
set(gcf,'defaulttextinterpreter','none','Visible','off','PaperOrientation', 'landscape','PaperPositionMode','manual', 'PaperPosition','O')
***********************************************************
Does any one have any ideas that would solve this
Many Thanks In Advance
James

采纳的回答

Daniel Shub
Daniel Shub 2012-8-8
Your posted code seems to have a couple of bugs. You create orientation as a cell array of strings and eventually pass one of those strings as the value of PaperPosition, but PaperPosition was a numeric array. Also, asking for the computer is probably not best. You can get it automatically with the OS hostname function (Windows and most Linux distros supply this function). Putting it all together ...
orientation = [0.05, 0.1, 12, 8; 0.1, 0.1,30, 20];
computerNames = {'WorkstationName'; 'LaptopName'};
[~, thiscomputer] = system('hostname');
option = strcmp(deblank(thiscomputer), computerNames);
set(gcf,'defaulttextinterpreter','none','Visible','off','PaperOrientation', 'landscape','PaperPositionMode','manual', 'PaperPosition',orientation(option, :))
  2 个评论
Oleg Komarov
Oleg Komarov 2012-8-8
编辑:Oleg Komarov 2012-8-8
First and accepted answer by James Hall moved to comment.
the issue that I am facing is that the code is there to reduce the need to change the code just to apply variables. It isnt guarunteed which computers will be using the script. thats why I was hoping to just use a input selection.
The script is intended for the non technical user just be able to pretty mindlessly process vast amounts of data on a weekly basis. I wouldnt be there to change the script to include different computers in the script.
or would the proposed script deal with that issue aswell?
many thanks for your reply
Oleg Komarov
Oleg Komarov 2012-8-8
编辑:Oleg Komarov 2012-8-8
Second answer by James Hall moved here as comment.
I have utilised your script as you said, and written a read me to make the new users add their system to the list computer names and spec.
thank you very much

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by