Retrieve BER values from Optisystem
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi
i'm trying to retrieve BER values from optisystem and save them into CSV file. At line 13, I receive this error: Unrecognized method, property, or field 'System' for class 'COM.OptiSystem_Application'.
% Retrieves BER Analyzer results and saves them to a CSV file.
% Define the path to your OptiSystem project
optisystemProjectPath = 'C:\Users\Me\Documents\FSO\Simulations\Turbulence.osd';
% Define output CSV file path
outputCSV = 'C:\Users\Me\Documents\FSO\Simulations\ber_results.csv';
% Start OptiSystem COM server
optisystem = actxserver('OptiSystem.Application');
% === project loading ===
systemDoc = optisystem.System;
systemDoc.Load(optisystemProjectPath);
% Run simulation
systemDoc.Calculate;
% === Retrieve BER values ===
berData = {};
componentCount = systemDoc.ComponentsCount;
for i = 1:componentCount
component = systemDoc.GetComponent(i);
compName = component.Name;
if contains(compName, 'BER Analyzer', 'IgnoreCase', true)
try
result = component.GetResult('BER');
berValue = result.GetValue;
berData{end+1,1} = compName; %#ok<SAGROW>
berData{end,2} = berValue;
fprintf('BER from %s: %e\n', compName, berValue);
catch ME
fprintf('No valid BER in %s (%s)\n', compName, ME.message);
end
end
end
% === Save results to CSV ===
if ~isempty(berData)
berTable = cell2table(berData, 'VariableNames', {'Component', 'BER'});
writetable(berTable, outputCSV);
fprintf('BER results saved to %s\n', outputCSV);
else
warning('No BER Analyzer components found.');
end
% Close project and release COM
systemDoc.Close;
delete(optisystem);
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre PHY Components en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!