- This topic has 1 reply, 2 voices, and was last updated 2 months, 2 weeks ago by
Saurabh Bedi.
-
AuthorPosts
-
-
January 13, 2025 at 2:08 pm #88820
唐振宇
Participant`clc;
close all;
clear all;f = 0.1;
A1 = 1;
A2 = 2;x1 = 0:0.1:10-0.1; % 对应y1和y1_1
x2 = 0:0.1:5-0.1; % 对应y2和y2_2
x3 = 5:0.1:10-0.1; % 对应y3和y3_2
x4 = 0:0.1:10/3-0.1; % 对应y4和y4_1
x5 = 10/3:0.1:10*2/3; % 对应y5和y5_1
x6 = 10*2/3:0.1:10-0.1; % 对应y6和y6_1% 信号生成
signals1 = {A1*sin(f*2*pi*x1), A2*sin(f*2*pi*x1)};
signals2 = { …
[A1*sin(2*f*2*pi*x2), A1*sin(2*f*2*pi*x3)], …
[A1*sin(2*f*2*pi*x2), A2*sin(2*f*2*pi*x3)], …
[A2*sin(2*f*2*pi*x2), A1*sin(2*f*2*pi*x3)], …
[A2*sin(2*f*2*pi*x2), A2*sin(2*f*2*pi*x3)]};
signals3 = { …
[A1*sin(3*f*2*pi*x4), A1*sin(3*f*2*pi*x5), A1*sin(3*f*2*pi*x6)], …
[A1*sin(3*f*2*pi*x4), A1*sin(3*f*2*pi*x5), A2*sin(3*f*2*pi*x6)], …
[A1*sin(3*f*2*pi*x4), A2*sin(3*f*2*pi*x5), A1*sin(3*f*2*pi*x6)], …
[A1*sin(3*f*2*pi*x4), A2*sin(3*f*2*pi*x5), A2*sin(3*f*2*pi*x6)], …
[A2*sin(3*f*2*pi*x4), A1*sin(3*f*2*pi*x5), A1*sin(3*f*2*pi*x6)], …
[A2*sin(3*f*2*pi*x4), A1*sin(3*f*2*pi*x5), A2*sin(3*f*2*pi*x6)], …
[A2*sin(3*f*2*pi*x4), A2*sin(3*f*2*pi*x5), A1*sin(3*f*2*pi*x6)], …
[A2*sin(3*f*2*pi*x4), A2*sin(3*f*2*pi*x5), A2*sin(3*f*2*pi*x6)]};% 可视化前3个信号
figure;
subplot(3,1,1); plot(x1, signals1{1}); title(‘Signal 1’);
subplot(3,1,2); plot(x1, signals2{2}); title(‘Signal 2’);
subplot(3,1,3); plot(x1, signals3{3}); title(‘Signal 3’);% 组合信号
combinedSignals = cell(64, 1);
counter = 1;for i = 1:length(signals1)
for j = 1:length(signals2)
for k = 1:length(signals3)
combinedSignals{counter} = signals1{i} + signals2{j} + signals3{k};
counter = counter + 1;
end
end
end% 拼接所有信号
total_signal = horzcat(combinedSignals{:});% 可视化第一个组合信号和总信号
figure;
subplot(2,1,1); plot(combinedSignals{1}); title(‘First Combined Signal’);
subplot(2,1,2); plot(total_signal); title(‘Concatenated Signal’);
xlabel(‘Sample Index’); ylabel(‘Amplitude’); -
January 13, 2025 at 2:14 pm #88904
Saurabh Bedi
ModeratorHello,
To input your signal from MATLAB in to OptiSystem, you can write a code to generate the signal and load that MATLAB file into the MATLAB Component with just a single output port. This way, your MATLAB component can behave as a Laser. For further understanding I suggest you to have a look at the MATLAB examples and make sure to follow the steps in the MATLAB files of these examples. I can see that you have attached a code for signal generation. Your code needs to match the format of MATLAB codes shown in the examples.
You can find the examples at: C:\Users\USERNAME\Documents\OptiSystem 22.0 Samples\Software interworking\MATLAB co-simulationAnother important point to keep in mind while running such simulations is, to make the number of samples and sample rate/bit rate match the global parameters of the simulation.
Let me know if you have any further queries. You can reach out to us at support@optiwave.com
Warm Regards,
Saurabh Bedi.
-
-
AuthorPosts
- You must be logged in to reply to this topic.