Skip to content
Snippets Groups Projects
Commit 435af87a authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

first working example

parent d7cc516b
No related branches found
No related tags found
No related merge requests found
function [IDf, Str] = FriendlyID(ID)
%FriendlyID Changes the Hex Number to a human friendly datetime and dateStr
%Remove Prefix
if contains(ID,'-')
IDarray = split(ID, '-');
ID = IDarray(2); %keep only the second part
end
ID = hex2dec(ID); % get it back as dec
IDf = datetime(ID,'ConvertFrom','posixtime');
Str = datestr(IDf);
end
function Publish(DataPaths, ID, figures, options)
%Publishes Saves Plot, Data and Measuring script
% Detailed explanation goes here
arguments
DataPaths
ID (1,:) {mustBeNonzeroLengthText} % ID must be provided
figures (1,:) {mustBeFigure} % Checks if Figures are figures
options
end
ServerPath = '\\FST-220\Jans-50GB-SMB\Lemmer';
FolderName = char(ID);
%% Create Data-Directory
addpath(ServerPath);
if mkdir(fullfile(ServerPath,FolderName))
else
error('Directory could not be created - check remote path and permissions');
end
disp('Publishing started');
%% Create a Copy of the script
try
%FileNameAndLocation=['C:\Users\Lemmer\Documents\GitLab\plot_identifier\MATLAB\test'];
FileNameAndLocation= DataPaths.script;
newbackup=sprintf([ID,'_script.m']);
currentfile=strcat(FileNameAndLocation, '.m');
% Write a Copy of the Plotting Script
RemotePath = fullfile(ServerPath,FolderName, newbackup);
copyfile(currentfile,RemotePath);
disp('Script sucessfully published');
catch
warning('Script export was not sucessful')
end
%% Create a copy of the research data
disp('Start to copy research data ...');
%try
FileNameAndLocation = DataPaths.rdata;
[~,~,ext] = fileparts(DataPaths.rdata); % get the extension
newbackup=sprintf([ID,'_data',ext]);
% Write a Copy of the Plotting Script
RemotePath = fullfile(ServerPath,FolderName, newbackup);
copyfile(FileNameAndLocation,RemotePath);
disp('Script sucessfully published');
%catch
%warning('Research data export was not sucessful')
%end
%% Export the Plots
%try
for i=1:numel(figures)
fig = figures(i);
PlotName = [ID,'_plot',num2str(i)]; % Der Plotnamen
RemotePath = fullfile(ServerPath ,FolderName, PlotName);
% Matlab figure
savefig(fig,RemotePath);
exportgraphics(fig,[RemotePath,'.png'],'Resolution',300);
disp([num2str(i),' of ',num2str(numel(figures)),' figures exported']);
end
%catch
%end
disp(['Publishing of ', ID , ' done']);
end %function
function tf = mustBeFigure(h) %checks if input is a figure object
tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');
end
function [figs] = TagPlot(figs, prefix)
function [figs, ID] = TagPlot(figs, prefix)
%TagPlot adds IDs to figures
% The ID is placed visual on the figure window and as Tag (Property of figure)
% TagPlot can Tag multiple figures at once
% TagPlot can tag multiple figures at once
arguments
figs (1,:) {mustBeFigure}
prefix (1,:) {mustBeText}= ''
......@@ -13,6 +13,7 @@ end
for n = 1:numel(figs)
ID = CreateID; % Create ID
ID = [prefix,'-',ID]; % add Prefix
axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
% Limits for relative Positioning
ylim =get(axes,'YLim');
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment