forked from JohannesLamo/Master_project_MRR_simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_input_signal_Github.m
More file actions
39 lines (32 loc) · 1.91 KB
/
Copy pathcreate_input_signal_Github.m
File metadata and controls
39 lines (32 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [Ein, input, target] = create_input_signal_Github(total_L, steps_per_bit, N_mask, Pin_avg_lin, bias, type, seed, P)
% This function does the following:
% - Creates an input signal
% - Creates a target function
% - converts the input signal to an electric field envelope
% which can be sent into the reservoir layer
if type == "ones"
input = ones(1,total_L);
target = ones(1,total_L);
elseif type == "NARMA_P"
[input, target] = NARMA_P_Github(total_L,P,seed);
else
error("No valid data type.")
end
% After the input and target signals are defined, we mask the input
% signal
mask_seed = 343; % Masking seed
rng(mask_seed); % Used for reproducability
mask = rand(1,N_mask); % Create mask of dimensions 1 X N_mask
M = steps_per_bit/N_mask; % Number of time steps per virtual node
mask_one_bit = repelem(mask, M); % Replicate the mask so that we have M steps per virtual node
masked_data_sequence = zeros(1, total_L*steps_per_bit); % Allocate for memory
% Multiply bit sequence by mask
for k = 1:total_L
idx_start = (k-1)*steps_per_bit + 1;
idx_end = k*steps_per_bit;
masked_data_sequence(idx_start:idx_end) = input(k)*mask_one_bit;
end
data_sequence = masked_data_sequence + bias; % Add bias to masked_data.
Pin = data_sequence/mean(data_sequence)*Pin_avg_lin; % Assume linear modulator. We want the average intensity = Pin_avg_lin.
Ein = sqrt(Pin); % Electric field envelope encoded with input data.
end