Select Git revision
-
Lemmer, Jan authoredLemmer, Jan authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
example.m 3.47 KiB
%% Example Script
% This Script is meant to demonstrate the capabilities of the PlotID tool.
%% Clear Environment
clear; clc; close all;
try
delete testdata2.h5;
end
%% Set ProjectID
% ProjectID can also be set in the config file
% Leave empty for using the ID from the config file
ProjectID = 'Example';
%% Data
% only necessary for this example
% Creating Random Data to use as data-file
x = linspace(0,7); y = rand(1,100)+2;
dataset1 = 'test_data.mat';
% Use absolute paths for good practise
dataset1 = fullfile(pwd,dataset1);
save(dataset1,'x','y');
% some data for the .h5 file
x1 = linspace(0,2*pi); y1 = sin(x1)+2;
% define filepath & name
dataset2 = 'testdata2.h5';
dataset2 = fullfile(pwd,dataset2);
fpath = dataset2;
% create hdf5 file and dataset > write data to hdf5 file / dataset
h5create(fpath, "/x1", size(x1), "Datatype", class(x1))
h5create(fpath, "/y1", size(y1), "Datatype", class(y1))
h5write(fpath, "/x1", x1)
h5write(fpath, "/y1", y1)
%% function calls
% Place for post-processing of the data, or additional related code.
% example_fcn is a dummy function to show the functionality
a = 1; a = example_fcn(a);
% Uncomment to include the Statistics and Machine learning Toolbox
% p = betacdf(0.5,1,1); % to test toolboxes
%% Plotting
% This is still part of a normal script to produce plots.
% Make sure to save each figure in a variable
% to pass it to PlotID-functions.
fig(1) = figure;
plot(x,y,'-k');
box off; hold on;
plot(x1,y1,'-r');
set(gca, 'TickDir', 'out', 'YLim', [0,4]);
%% Example 1: single plot based on two data-sets
%% Tag the plot
% PlotID Implementation starts here.
% TagPlot adds a visible ID to the figure(s) and to the figures property
% 'Tag'
[fig, ID] = PlotID.TagPlot(fig, 'ProjectID', ProjectID);
%% Publishing
% Second part of plotID
% The functions needs the file location of the script, the location of the
% data and the figure and can take several options (see readme).