database_type = 'mysql'; dataBase = 'labor_highspeed';%'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\silas_labor_newdsp_newstructure.db'; db = DBHandler("dataBase", [dataBase], "type", database_type); fp = QueryFilter(); fp.where('power_state_info', 'pam_level','EQUALS', 4); fp.where('power_state_info', 'db_mode','EQUALS', 1); % fp.where('power_state_info', 'fiber_length','EQUALS', 1); fp.where('power_state_info', 'is_mpi','EQUALS', 0); fields = db.getTableFieldNames('power_state_info'); % [dataTable,~] = db.queryDB(fp, fields); fiber_len = unique(dataTable.fiber_length); cnt = 0; y_variable = 'power_mzm'; x_variable = "wavelength"; f = figure(3); clf hold on for fl = 1:numel(fiber_len) fl_filtered = dataTable(dataTable.fiber_length == fiber_len(fl),:); [~, ia] = unique(fl_filtered.run_id, 'first'); fl_filtered = fl_filtered(ia, :); fl_filtered_ = groupsummary( ... fl_filtered, ... % input table x_variable, ... % grouping variable "mean", ... % which summary statistic y_variable); % which column to average wavelength_sorted = sortrows(fl_filtered, {'wavelength'}, 'ascend'); % pull out your vectors lambda = wavelength_sorted.wavelength; power_laser = wavelength_sorted.power_laser; power_mzm = wavelength_sorted.power_mzm; power_rop = wavelength_sorted.power_rop; power_pd = wavelength_sorted.power_pd_in; voa = wavelength_sorted.voa_atten; len = wavelength_sorted.fiber_length; run_ids = wavelength_sorted.run_id; % <-- this is what we want in the datatip cols = linspecer(8); % plot the two curves and capture their Line handles % h1 = plot(lambda, power_laser,'LineWidth', 0.5, 'MarkerSize', 4,'Marker','o','LineStyle','none','Color',cols(fl,:),'MarkerFaceColor',cols(fl,:),'DisplayName','Laser Output'); % % —————— Add run_id as a datatip row —————— % % For each line, tell the datatip template where to find the run_id: % h1.DataTipTemplate.DataTipRows(end+1) = ... % dataTipTextRow('run\_id', run_ids); % h1.DataTipTemplate.DataTipRows(end+1) = ... % dataTipTextRow('len', run_ids); % h1.DataTipTemplate.DataTipRows(end+1) = ... % dataTipTextRow('voaatten', voa); % dname = sprintf('%s; %d km',y_variable, fiber_len(fl)); h2 = plot(fl_filtered_.(x_variable), fl_filtered_.(['mean_',y_variable]), 'LineWidth', 1, 'MarkerSize', 4,'Marker','o','LineStyle','-','Color',cols(fl,:),'MarkerFaceColor',cols(fl,:),'DisplayName',dname); h2.DataTipTemplate.DataTipRows(end+1) = ... dataTipTextRow('run\_id', run_ids); h2.DataTipTemplate.DataTipRows(end+1) = ... dataTipTextRow('len', len); h2.DataTipTemplate.DataTipRows(end+1) = ... dataTipTextRow('voaatten', voa); grid on; xticks(sort(unique(lambda))); xticklabels(sort(unique(lambda))); % Labels, scales, legend, etc. xlabel('Wavelength in nm','FontSize',12); ylabel('Power in dB','FontSize',12); title('Power ','FontSize',14,'FontWeight','bold'); set(gca, 'XScale','linear','YScale','linear','FontSize',11); legend xlim([min(lambda)-2, max(lambda)+2]); ylim([floor(min(fl_filtered_.(['mean_',y_variable])))-1 12]); ylim([-12 12]); cnt = cnt+1; yline(8,'HandleVisibility','off'); end yline([4.85e-3, 2e-2],'--','LineWidth',1,'HandleVisibility','off'); posH = get(f, 'Position'); % [left, bottom, width, height] newPos = [posH(1), posH(2), 750, 300]; set(f, 'Position', newPos);