Auswertung Experiment
Database tüddelei DBHanlder läuft gut für DIESE Datanbank struktur... App begonnen aber weit entfernt von gutem Stand
This commit is contained in:
53
Libs/mat2tikz/test/examples/example_bar_plot.m
Normal file
53
Libs/mat2tikz/test/examples/example_bar_plot.m
Normal file
@@ -0,0 +1,53 @@
|
||||
function example_bar_plot()
|
||||
test_data =[18 0; 20 0; 21 2; 30 14; 35 34; 40 57; 45 65; 50 46; 55 9; 60 2; 65 1; 70 0];
|
||||
|
||||
% Create figure
|
||||
figure1 = figure('Color',[1 1 1]);
|
||||
|
||||
subplot(1,2,1)
|
||||
|
||||
|
||||
hb=barh(test_data(:,1),test_data(:,2),'DisplayName','Test Data');
|
||||
|
||||
ylabel('parameter [units]');
|
||||
xlabel('#');
|
||||
legend('show','Location','northwest');
|
||||
subplot(1,2,2)
|
||||
|
||||
|
||||
hb=bar(test_data(:,1),test_data(:,2),'DisplayName','Test Data');
|
||||
|
||||
xlabel('parameter [units]');
|
||||
ylabel('#');
|
||||
legend('show','Location','northwest');
|
||||
|
||||
|
||||
xdata=test_data(:,1);
|
||||
barWidth=test_getBarWidthInAbsolutUnits(hb);
|
||||
|
||||
x_l=xdata-barWidth/2;
|
||||
x_u=xdata+barWidth/2;
|
||||
max_y=max(test_data(:,2))*1.2;
|
||||
x=[];
|
||||
y=[];
|
||||
for i=1:length(x_l)
|
||||
x = [x , x_l(i),x_l(i),nan,x_u(i),x_u(i),nan];
|
||||
y = [y, 0,max_y ,nan,0 ,max_y ,nan];
|
||||
|
||||
|
||||
end
|
||||
hold on
|
||||
plot(x,y,'r');
|
||||
|
||||
matlab2tikz('figurehandle',figure1,'filename','example_v_bar_plot.tex' ,'standalone', true);
|
||||
|
||||
|
||||
function BarWidth=test_getBarWidthInAbsolutUnits(h)
|
||||
% astimates the width of a bar plot
|
||||
XData_bar=get(h,'XData');
|
||||
length_bar = length(XData_bar);
|
||||
BarWidth= get(h, 'BarWidth');
|
||||
if length_bar > 1
|
||||
BarWidth = min(diff(XData_bar))*BarWidth;
|
||||
end
|
||||
|
||||
80
Libs/mat2tikz/test/examples/example_quivers.m
Normal file
80
Libs/mat2tikz/test/examples/example_quivers.m
Normal file
@@ -0,0 +1,80 @@
|
||||
%% Quiver calculations
|
||||
% These are calculations for the quiver dimensions as implemented in MATLAB
|
||||
% (HG1) as in the |quiver.m| function.
|
||||
%
|
||||
% For HG2 and Octave, the situation might be different.
|
||||
%
|
||||
% A single quiver is defined as:
|
||||
%
|
||||
% C
|
||||
% \
|
||||
% \
|
||||
% A ----------------- B
|
||||
% /
|
||||
% /
|
||||
% D
|
||||
%
|
||||
% To know the dimensions of the arrow head, MATLAB defines the quantities
|
||||
% alpha = beta = 0.33 that determine the coordinates of C and D as given below.
|
||||
|
||||
clc;
|
||||
clear variables;
|
||||
close all;
|
||||
|
||||
%% Parameters
|
||||
try
|
||||
syms x y z u v w alpha beta epsilon real
|
||||
catch
|
||||
warning('Symbolic toolbox not found. Interpret the values with care!');
|
||||
x = randn(); y = randn(); z = randn();
|
||||
u = randn(); v = randn(); w = randn();
|
||||
end
|
||||
alpha = 0.33;
|
||||
beta = alpha;
|
||||
epsilon = 0;
|
||||
is2D = true;
|
||||
|
||||
%% Coordinates as defined in MATLAB
|
||||
% Note that in 3D, the arrow head is oriented in a weird way. Let' just ignore
|
||||
% that and only focus on 2D and use the same in 3D. Due to the lack
|
||||
% of [u,v,w]-symmetry in those equations, the angle is bound to depend on the
|
||||
% length of |delta|, i.e. something we don't know beforehand.
|
||||
A = [x y z].';
|
||||
delta = [u v w].';
|
||||
B = A + delta;
|
||||
C = B - alpha*[u+beta*(v+epsilon);
|
||||
v-beta*(u+epsilon)
|
||||
w];
|
||||
D = B - alpha*[u-beta*(v+epsilon);
|
||||
v+beta*(u+epsilon)
|
||||
w];
|
||||
|
||||
if is2D
|
||||
A = A(1:2);
|
||||
B = B(1:2);
|
||||
C = C(1:2);
|
||||
D = D(1:2);
|
||||
delta = delta(1:2);
|
||||
end
|
||||
|
||||
%% Calculating the angle of the arrowhead
|
||||
% Calculate the cos(angle) using the inner product
|
||||
unitVector = @(v) v/norm(v);
|
||||
cosAngleBetween = @(a,b,c) unitVector(a-b).' * unitVector(c-b);
|
||||
|
||||
cosTwiceTheta = cosAngleBetween(C,B,D);
|
||||
if isa(cosTwiceTheta, 'sym')
|
||||
cosTwiceTheta = simplify(cosTwiceTheta);
|
||||
end
|
||||
|
||||
theta = acos(cosTwiceTheta) / 2
|
||||
|
||||
radToDeg = @(rads) (rads * 180 / pi);
|
||||
|
||||
thetaVal = radToDeg(theta)
|
||||
try
|
||||
thetaVal = double(thetaVal)
|
||||
end
|
||||
|
||||
% For the MATLAB parameters alpha=beta=0.33, we get theta = 18.263 degrees.
|
||||
|
||||
Reference in New Issue
Block a user