Home Forums SYSTEM co-simulation with matlab

co-simulation with matlab

Profile Photo
(joined November 2014)
Participant

Dear all,

I am a beginner with optisystem, especially for co-simulation with matlab. To understand details of cosimulation. I built sine wave generator with matlab component in optisystem. I havent figured out why it doesn’t work. the matlab code as following:

OutputPort1 = InputPort1;
As=1; % amplitude of sine wave
fc=Parameter1*1e9; % sine wave with 15 GHz
fs=Parameter2; % sample rate
tw=Parameter0; % time window
t=[0:1/fs:tw-1/fs];

cs = length(t);
sw = As*sin(2*pi*fc*t);

for m=1:cs
OutputPort1.Sampled.Signal(m) = sw(m);
end

Responses (4):

    • #16746
      Profile Photo
      zsliu
      Participant

      Dear all,

      I am a beginner with optisystem, especially for co-simulation with matlab. To understand details of cosimulation. I built sine wave generator with matlab component in optisystem. I havent figured out why it doesn’t work. the matlab code as following:

      OutputPort1 = InputPort1;
      As=1; % amplitude of sine wave
      fc=Parameter1*1e9; % sine wave with 15 GHz
      fs=Parameter2; % sample rate
      tw=Parameter0; % time window
      t=[0:1/fs:tw-1/fs];

      cs = length(t);
      sw = As*sin(2*pi*fc*t);

      for m=1:cs
      OutputPort1.Sampled.Signal(m) = sw(m);
      end

    • #16748
      Profile Photo
      zsliu
      Participant

      just to upload osd file. it maybe has problem to pass global parameters sample rate and time window to matlab. but even I used fs=640e9; tw=12.8e-9; the output is still null.

    • #16752
      Profile Photo
      zsliu
      Participant

      I have figured out. the code should be as following.
      As=1; % amplitude of sine wave
      fc=Parameter1*1e9; % sine wave with 15 GHz
      fs=Parameter2; % sample rate
      tw=Parameter0; % time window

      t=[0:1/fs:tw-1/fs];
      Time = t;
      cs = length(t);
      sw = As*sin(2*pi*fc*t);
      OutputPort1.TypeSignal = ‘Electrical’;
      OutputPort1.Noise = [];
      OutputPort1.IndividualSample = [];
      OutputPort1.Sampled.Signal = sw;
      OutputPort1.Sampled.Time = t;

      +1
      • #16756
        Profile Photo
        Damian Marek
        Participant

        Good job figuring it out! Could you attach the M-file as well, so if users come upon this post they can try it out?

        Thanks

    • #16765
      Profile Photo
      zsliu
      Participant

      Thanks. please file the attached for M-file.

      Attachments:

Login You must be logged in to reply to this topic.