Name a dataset that will be used in Simulink
How do I name a dataset. My dataset is available in Simulink; however, it is identified as unnamed. I want to use multiple datasets so I need to be able to identify each of them separately.
clc
% Parameters
f0 = 60; % Fundamental frequency in Hz
sampling_rate = 120000; % Sampling rate in Hz
stopTime = 0.1; % Duration of the signal in seconds
t = 0:1/sampling_rate:stopTime; % Time vector
% Harmonic amplitudes (example values)
IA = [771.32, 0.24,1.36, 0.96, 6.64, 0.16, 2.36, 0, 0.48,…
0.16, 1.84, 0.08, 0.56, 0.08, 0.32, 0.08, 0.24,…
0.08, 0.08, 0.08, 0.08, 0, 0.48, 0, 0.16, 0.08, 0.08, 0, 0.08, 0, 0, 0, 0,…
0.08, 0.24, 0.16, 0.32, 0.08, 0.08, 0.08, 0.32,…
0.08, 0.24, 0.16, 0.24, 0.08, 0.8, 0.16, 0.48,…
0.16, 0.16, 0.08, 0.72, 0.24, 0.72, 0.16, 0.24,…
0.08, 0.16, 0.08, 0.56, 0.08, 0.32]’; % Amplitudes for the 1st, 2nd, and 3rd harmonics
IB = [773.44, 0.4, 0.72, 0.88, 6.16, 0.4, 2.84, 0.08, 0.4, 0.08,…
1.76, 0.08, 0.96, 0.08, 0.16, 0, 0.4, 0.08, …
0.24, 0.08, 0, 0, 0.4, 0, 0.24, 0,…
0.08, 0, 0.08, 0, 0.08, 0, 0.16, 0.08,…
0.16, 0.08, 0.32, 0.08, 0.08, 0, 0.24, 0.08,…
0.4, 0.08, 0.08, 0.08, 0.8, 0.08, 0.72, 0.16,…
0.08, 0.32, 0.48, 0, 0.08, 0.08, 0.24, 0.32,…
0.24, 0.24, 0.72, 0.24, 0.08];
IC = [775.76, 0.24, 0.56, 0.72, 6.48, 0.24, 2.44, 0.08, 0.08, 0.08, …
2.12, 0, 0.72, 0.08, 0.16, 0.08,…
0.32, 0, 0.08, 0, 0, 0, 0.56, 0, 0.08, 0, 0.08, 0, …
0, 0, 0.08, 0, 0, 0, 0.24, 0, 0.24, 0, 0, 0.08, 0.24, 0, 0.32, 0,…
0.08, 0.08, 0.8, 0.08, 0.56, 0.08, 0.32, 0.08,…
0.64, 0.32, 0.56, 0.08, 0.24, 0.32, 0.24, 0.32, 0.72, 0.16, 0.24];
%% Generate the current
currentIA = zeros(size(t));
currentIB = zeros(size(t));
currentIC = zeros(size(t));
for n = 1:length(IA)
amplitudeIA = IA(n);
currentIA = currentIA + amplitudeIA * cos(2 * pi * n * f0 * t);
amplitudeIB = IB(n);
currentIB = currentIB + amplitudeIB * cos(2 * pi * n * f0 * t + 2*pi/3);
amplitudeIC = IC(n);
currentIC = currentIC + amplitudeIC * cos(2 * pi * n * f0 * t – 2*pi/3);
end
currents = timeseries([currentIA; currentIB; currentIC]’, t);
dataset = Simulink.SimulationData.Dataset(currents); %How do I give the dataset a name?
save currentsWith63Harmonics.mat dataset
%% Plot the signal
figure(1);
plot(t, currentIA);
hold on
plot(t, currentIB);
plot(t, currentIC);
title(‘Three-Phase currents with 63 harmonics’);
xlabel(‘Time (s)’);
ylabel(‘A’);
grid on;
figure(2);
ee_calculateThdPercent(1:1:63,IA’)
bar(1:1:63,IA’)
clear IA IB IC f0 duration amplitudeIA amplitudeIB amplitudeIC
clear n t signalHow do I name a dataset. My dataset is available in Simulink; however, it is identified as unnamed. I want to use multiple datasets so I need to be able to identify each of them separately.
clc
% Parameters
f0 = 60; % Fundamental frequency in Hz
sampling_rate = 120000; % Sampling rate in Hz
stopTime = 0.1; % Duration of the signal in seconds
t = 0:1/sampling_rate:stopTime; % Time vector
% Harmonic amplitudes (example values)
IA = [771.32, 0.24,1.36, 0.96, 6.64, 0.16, 2.36, 0, 0.48,…
0.16, 1.84, 0.08, 0.56, 0.08, 0.32, 0.08, 0.24,…
0.08, 0.08, 0.08, 0.08, 0, 0.48, 0, 0.16, 0.08, 0.08, 0, 0.08, 0, 0, 0, 0,…
0.08, 0.24, 0.16, 0.32, 0.08, 0.08, 0.08, 0.32,…
0.08, 0.24, 0.16, 0.24, 0.08, 0.8, 0.16, 0.48,…
0.16, 0.16, 0.08, 0.72, 0.24, 0.72, 0.16, 0.24,…
0.08, 0.16, 0.08, 0.56, 0.08, 0.32]’; % Amplitudes for the 1st, 2nd, and 3rd harmonics
IB = [773.44, 0.4, 0.72, 0.88, 6.16, 0.4, 2.84, 0.08, 0.4, 0.08,…
1.76, 0.08, 0.96, 0.08, 0.16, 0, 0.4, 0.08, …
0.24, 0.08, 0, 0, 0.4, 0, 0.24, 0,…
0.08, 0, 0.08, 0, 0.08, 0, 0.16, 0.08,…
0.16, 0.08, 0.32, 0.08, 0.08, 0, 0.24, 0.08,…
0.4, 0.08, 0.08, 0.08, 0.8, 0.08, 0.72, 0.16,…
0.08, 0.32, 0.48, 0, 0.08, 0.08, 0.24, 0.32,…
0.24, 0.24, 0.72, 0.24, 0.08];
IC = [775.76, 0.24, 0.56, 0.72, 6.48, 0.24, 2.44, 0.08, 0.08, 0.08, …
2.12, 0, 0.72, 0.08, 0.16, 0.08,…
0.32, 0, 0.08, 0, 0, 0, 0.56, 0, 0.08, 0, 0.08, 0, …
0, 0, 0.08, 0, 0, 0, 0.24, 0, 0.24, 0, 0, 0.08, 0.24, 0, 0.32, 0,…
0.08, 0.08, 0.8, 0.08, 0.56, 0.08, 0.32, 0.08,…
0.64, 0.32, 0.56, 0.08, 0.24, 0.32, 0.24, 0.32, 0.72, 0.16, 0.24];
%% Generate the current
currentIA = zeros(size(t));
currentIB = zeros(size(t));
currentIC = zeros(size(t));
for n = 1:length(IA)
amplitudeIA = IA(n);
currentIA = currentIA + amplitudeIA * cos(2 * pi * n * f0 * t);
amplitudeIB = IB(n);
currentIB = currentIB + amplitudeIB * cos(2 * pi * n * f0 * t + 2*pi/3);
amplitudeIC = IC(n);
currentIC = currentIC + amplitudeIC * cos(2 * pi * n * f0 * t – 2*pi/3);
end
currents = timeseries([currentIA; currentIB; currentIC]’, t);
dataset = Simulink.SimulationData.Dataset(currents); %How do I give the dataset a name?
save currentsWith63Harmonics.mat dataset
%% Plot the signal
figure(1);
plot(t, currentIA);
hold on
plot(t, currentIB);
plot(t, currentIC);
title(‘Three-Phase currents with 63 harmonics’);
xlabel(‘Time (s)’);
ylabel(‘A’);
grid on;
figure(2);
ee_calculateThdPercent(1:1:63,IA’)
bar(1:1:63,IA’)
clear IA IB IC f0 duration amplitudeIA amplitudeIB amplitudeIC
clear n t signal How do I name a dataset. My dataset is available in Simulink; however, it is identified as unnamed. I want to use multiple datasets so I need to be able to identify each of them separately.
clc
% Parameters
f0 = 60; % Fundamental frequency in Hz
sampling_rate = 120000; % Sampling rate in Hz
stopTime = 0.1; % Duration of the signal in seconds
t = 0:1/sampling_rate:stopTime; % Time vector
% Harmonic amplitudes (example values)
IA = [771.32, 0.24,1.36, 0.96, 6.64, 0.16, 2.36, 0, 0.48,…
0.16, 1.84, 0.08, 0.56, 0.08, 0.32, 0.08, 0.24,…
0.08, 0.08, 0.08, 0.08, 0, 0.48, 0, 0.16, 0.08, 0.08, 0, 0.08, 0, 0, 0, 0,…
0.08, 0.24, 0.16, 0.32, 0.08, 0.08, 0.08, 0.32,…
0.08, 0.24, 0.16, 0.24, 0.08, 0.8, 0.16, 0.48,…
0.16, 0.16, 0.08, 0.72, 0.24, 0.72, 0.16, 0.24,…
0.08, 0.16, 0.08, 0.56, 0.08, 0.32]’; % Amplitudes for the 1st, 2nd, and 3rd harmonics
IB = [773.44, 0.4, 0.72, 0.88, 6.16, 0.4, 2.84, 0.08, 0.4, 0.08,…
1.76, 0.08, 0.96, 0.08, 0.16, 0, 0.4, 0.08, …
0.24, 0.08, 0, 0, 0.4, 0, 0.24, 0,…
0.08, 0, 0.08, 0, 0.08, 0, 0.16, 0.08,…
0.16, 0.08, 0.32, 0.08, 0.08, 0, 0.24, 0.08,…
0.4, 0.08, 0.08, 0.08, 0.8, 0.08, 0.72, 0.16,…
0.08, 0.32, 0.48, 0, 0.08, 0.08, 0.24, 0.32,…
0.24, 0.24, 0.72, 0.24, 0.08];
IC = [775.76, 0.24, 0.56, 0.72, 6.48, 0.24, 2.44, 0.08, 0.08, 0.08, …
2.12, 0, 0.72, 0.08, 0.16, 0.08,…
0.32, 0, 0.08, 0, 0, 0, 0.56, 0, 0.08, 0, 0.08, 0, …
0, 0, 0.08, 0, 0, 0, 0.24, 0, 0.24, 0, 0, 0.08, 0.24, 0, 0.32, 0,…
0.08, 0.08, 0.8, 0.08, 0.56, 0.08, 0.32, 0.08,…
0.64, 0.32, 0.56, 0.08, 0.24, 0.32, 0.24, 0.32, 0.72, 0.16, 0.24];
%% Generate the current
currentIA = zeros(size(t));
currentIB = zeros(size(t));
currentIC = zeros(size(t));
for n = 1:length(IA)
amplitudeIA = IA(n);
currentIA = currentIA + amplitudeIA * cos(2 * pi * n * f0 * t);
amplitudeIB = IB(n);
currentIB = currentIB + amplitudeIB * cos(2 * pi * n * f0 * t + 2*pi/3);
amplitudeIC = IC(n);
currentIC = currentIC + amplitudeIC * cos(2 * pi * n * f0 * t – 2*pi/3);
end
currents = timeseries([currentIA; currentIB; currentIC]’, t);
dataset = Simulink.SimulationData.Dataset(currents); %How do I give the dataset a name?
save currentsWith63Harmonics.mat dataset
%% Plot the signal
figure(1);
plot(t, currentIA);
hold on
plot(t, currentIB);
plot(t, currentIC);
title(‘Three-Phase currents with 63 harmonics’);
xlabel(‘Time (s)’);
ylabel(‘A’);
grid on;
figure(2);
ee_calculateThdPercent(1:1:63,IA’)
bar(1:1:63,IA’)
clear IA IB IC f0 duration amplitudeIA amplitudeIB amplitudeIC
clear n t signal naming datasets in matlab MATLAB Answers — New Questions