122 lines
4.2 KiB
Matlab
122 lines
4.2 KiB
Matlab
% =========================================================================
|
|
% MATLAB PLOT & EXPORT SKRIPT (OHNE MARKER)
|
|
% =========================================================================
|
|
|
|
% 1. Parameter für den Moving Average Filter definieren
|
|
window_size = 50;
|
|
|
|
% 2. Ordner für den Bildexport erstellen
|
|
outputFolder = 'Plots_Export';
|
|
if ~exist(outputFolder, 'dir')
|
|
mkdir(outputFolder);
|
|
end
|
|
|
|
% 3. Strukturen und aktualisierte Legenden-Labels
|
|
structs = {S0, S2, S4, S6, S8, S10};
|
|
labels = {
|
|
'S0 (0 kg)', ...
|
|
'S2 (9 kg)', ...
|
|
'S4 (18 kg)', ...
|
|
'S6 (27 kg)', ...
|
|
'S8 (36 kg)', ...
|
|
'S10 (45 kg)'
|
|
};
|
|
|
|
% 4. Entitäten definieren
|
|
entities = {'ACTPOS', 'SETPOS', 'ACTVELO', 'POSDIFF', 'ActTorque', 'current_mA'};
|
|
|
|
% 5. Farbpalette (explizite RGB-Matrix)
|
|
colors = [
|
|
0.00, 0.45, 0.74; % S0 - Blau
|
|
0.85, 0.33, 0.10; % S2 - Orange
|
|
0.93, 0.69, 0.13; % S4 - Gelb
|
|
0.49, 0.18, 0.56; % S6 - Violett
|
|
0.47, 0.67, 0.19; % S8 - Grün
|
|
0.30, 0.75, 0.93 % S10 - Hellblau
|
|
];
|
|
|
|
% Umrechnungsfaktoren
|
|
torque_factor = 0.5 / 100; % 100% = 0.5 Nm
|
|
uA_to_A_factor = 1e-6; % uA in Ampere
|
|
|
|
% 6. Schleife über alle Entitäten
|
|
for e = 1:length(entities)
|
|
entityName = entities{e};
|
|
|
|
fig = figure('Name', entityName, 'NumberTitle', 'off', 'Visible', 'on');
|
|
fig.Position = [100, 100, 1200, 700];
|
|
|
|
hold on;
|
|
grid on;
|
|
|
|
if strcmp(entityName, 'ActTorque')
|
|
% --- SONDERFALL: ActTorque mit Moving Average & zwei Y-Achsen ---
|
|
|
|
% Linke Achse: Gefilterte Daten in %
|
|
yyaxis left
|
|
for s = 1:length(structs)
|
|
S = structs{s};
|
|
if isfield(S, entityName) && isfield(S.(entityName), 't') && isfield(S.(entityName), 'y')
|
|
y_filtered = movmean(S.(entityName).y, window_size);
|
|
|
|
plot(S.(entityName).t, y_filtered, 'LineWidth', 1.5, ...
|
|
'Marker', 'none', 'Color', colors(s, :), 'DisplayName', labels{s});
|
|
end
|
|
end
|
|
ylabel(['Drehmoment [%] (MA, n=', num2str(window_size), ')']);
|
|
|
|
% Rechte Achse: Gefilterte Umgerechnete Daten in Nm
|
|
yyaxis right
|
|
for s = 1:length(structs)
|
|
S = structs{s};
|
|
if isfield(S, entityName) && isfield(S.(entityName), 't') && isfield(S.(entityName), 'y')
|
|
y_filtered_Nm = movmean(S.(entityName).y, window_size) * torque_factor;
|
|
|
|
plot(S.(entityName).t, y_filtered_Nm, 'LineWidth', 1.5, ...
|
|
'Marker', 'none', 'Color', colors(s, :), 'HandleVisibility', 'off');
|
|
end
|
|
end
|
|
ylabel(['Drehmoment [Nm] (MA, n=', num2str(window_size), ')']);
|
|
|
|
ax = gca;
|
|
ax.YAxis(1).Color = 'k';
|
|
ax.YAxis(2).Color = 'k';
|
|
|
|
elseif strcmp(entityName, 'current_mA')
|
|
% --- SONDERFALL: current_mA von uA in Ampere umrechnen ---
|
|
for s = 1:length(structs)
|
|
S = structs{s};
|
|
if isfield(S, entityName) && isfield(S.(entityName), 't') && isfield(S.(entityName), 'y')
|
|
y_A = S.(entityName).y * uA_to_A_factor;
|
|
|
|
plot(S.(entityName).t, y_A, 'LineWidth', 1.5, ...
|
|
'Marker', 'none', 'Color', colors(s, :), 'DisplayName', labels{s});
|
|
end
|
|
end
|
|
ylabel('Strom [A]');
|
|
|
|
else
|
|
% --- STANDARD-PLOTS für alle anderen Entitäten ---
|
|
for s = 1:length(structs)
|
|
S = structs{s};
|
|
if isfield(S, entityName) && isfield(S.(entityName), 't') && isfield(S.(entityName), 'y')
|
|
plot(S.(entityName).t, S.(entityName).y, 'LineWidth', 1.5, ...
|
|
'Marker', 'none', 'Color', colors(s, :), 'DisplayName', labels{s});
|
|
end
|
|
end
|
|
ylabel(['Wert (', entityName, ')']);
|
|
end
|
|
|
|
hold off;
|
|
xlabel('Zeit t [s]');
|
|
title(['Verlauf von ', entityName]);
|
|
legend('Location', 'bestoutside');
|
|
|
|
% Bild speichern
|
|
fileName = fullfile(outputFolder, ['Plot_', entityName, '.png']);
|
|
exportgraphics(fig, fileName, 'Resolution', 300);
|
|
|
|
fprintf('Plot gespeichert: %s\n', fileName);
|
|
end
|
|
|
|
disp('Alle Plots wurden erfolgreich ohne Marker generiert und gespeichert.'); |