i am learning optical attenuation and wanted to learn more by using matlab since i am new to matlab i didn't understood this error___Undefined function or variable 'InputPort1'. Error in a (line 2) OutputPort1 = InputPort1;____so can please help me
1 view (last 30 days)
Show older comments
%
% This program simulates an attenuator
% Input parameter - Attenuation constant X [dB]
% Input parameter - Attenuation constant Y [dB]
% create an output structure similar to the input
OutputPort1 = InputPort1;
% Attenuation constants
AttenuationX = Parameter0;
AttenuationY = Parameter1;if(InputPort1.TypeSignal == 'Optical')
[ls, cs] = size(InputPort1.Sampled);
if( ls > 0 )
for counter1=1:cs
% Calculate the signal attenuated in the x polarization
OutputPort1.Sampled(1, counter1).Signal(1,:) = InputPort1.Sampled(1, counter1).Signal(1,:) * exp(-0.2303 *
AttenuationX / 2);
% Calculate the signal attenuated in the Y polarization if it exists
if(size(InputPort1.Sampled(1, counter1).Signal,1) > 1)
OutputPort1.Sampled(1, counter1).Signal(2,:) = InputPort1.Sampled(1, counter1).Signal(2,:) * exp(-0.2303 *
AttenuationY / 2);
end
end
end
% verify how many parameterized signals are in the structure
[lp, cp] = size(InputPort1.Parameterized);
if( lp > 0 )
% Calculate the signal attenuated in the x polarization
PowerTempX = InputPort1.Parameterized.Power .* (1 - InputPort1.Parameterized.SplittingRatio) * exp(-0.2303 *
AttenuationX );
% Calculate the signal attenuated in the y polarization
PowerTempY = InputPort1.Parameterized.Power .* InputPort1.Parameterized.SplittingRatio * exp(-0.2303 *
AttenuationY );
% Calculate the new total optical power at the signal
OutputPort1.Parameterized.Power = PowerTempX + PowerTempY;
% Calculate the new Splitting Ratio at the signal
OutputPort1.Parameterized.SplittingRatio = PowerTempY ./ (PowerTempX + PowerTempY);
end
end
Noise bins Signal – Noise bins represent
1 Comment
ahmed majid
on 5 Nov 2021
Edited: ahmed majid
on 5 Nov 2021
Dear mr,
Could you please explain the kind of attenuter did you use?.
best regards
Answers (2)
Walter Roberson
on 7 Dec 2012
It looks to me as if that code is intended to run as part of a MATLAB "function" within Simulink. Was there a line that started with the word "function" before what you showed?
2 Comments
haydr sami
on 19 Feb 2023
hi ahmed majid This code does not work for a unit that must be linked to the OptiSystem program, as it is intended for this
0 Comments
See Also
Categories
Find more on Optics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!