Borrar filtros
Borrar filtros

Unable to use the variable from workspace which is sent to the MATLAB workspace using 'To workspace' block of the Simulink.

3 visualizaciones (últimos 30 días)
I have a signal of my Simulink model which I have named as 'Fs'. I am using 'To workspace' block of the Simulink to store the signal in MATLAB workspace. The variable name is 'Fs' and the save format is 'Structure With Time' . The signal 'Fs' is not a vector, it is a 1 dimensional signal (basically it is a frequency signal of a Power Transmission System i..e. 50Hz ). I want to apply Empirical Mode Decomposition on this frequency signal. When I run the code it gives me the following error.. Error using load
Unable to read file 'IEEE_14_Bus_System_SM_FFR.mat'. No such file or directory.
Following is my code...
% Load the frequency signal from Simulink
load('IEEE_14_Bus_System_SM_FFR.mat', 'Fs');
freq_signal = Fs.signals.values;
disp(freq_signal)
% Step 1: Find extrema and obtain upper and lower envelopes
sampling_rate = 1000; % Hz
[~, upper_env] = envelope(freq_signal,round(sampling_rate/20),'peak');
[~, lower_env] = envelope(freq_signal,round(sampling_rate/20),'trough');
% Step 2: Compute the mean envelope
mean_env = (upper_env + lower_env)/2;
% Step 3: Initialize k and perform empirical mode decomposition
k = 1;
imf = [];
residual = freq_signal;
while true
% Step 3a: Extract the kth IMF
[imf_k,~,residual_k] = emd(residual-mean_env,'Display',0,'MaxNumIMF',1);
imf = [imf imf_k];
disp(imf)
% Step 3b: Check if the kth IMF is the last IMF
if size(residual_k,1) < 2
imf = [imf residual_k];
break;
end
% Step 3c: Prepare for next iteration
k = k + 1;
residual = residual_k;
end
% Step 4: Compute the residuals and extract additional IMFs
residual = freq_signal - imf;
imf2 = [];
while true
% Step 4a: Extract the next IMF
[imf_k,~,residual_k] = emd(residual-mean_env,'Display',0,'MaxNumIMF',1);
imf2 = [imf2 imf_k];
% Step 4b: Check if the kth IMF is the last IMF
if size(residual_k,1) < 2
imf2 = [imf2 residual_k];
break;
end
% Step 4c: Prepare for next iteration
residual = residual_k;
end
% Step 5: Compute the derivatives of the IMFs
for i = 1:size(imf,2)
deriv_imf(:,i) = gradient(imf(:,i));
end
for i = 1:size(imf2,2)
deriv_imf2(:,i) = gradient(imf2(:,i));
end
disp(deriv_imf2)
Can any staff members assist in this regard???

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 7 de Mzo. de 2023
"Unable to read file 'IEEE_14_Bus_System_SM_FFR.mat'. No such file or directory."
Make sure you have that .mat file. Use Command Line to load it, check 'Fs' is there and have the right data.
  5 comentarios
Paul
Paul el 7 de Mzo. de 2023
Can also use the To File block to save directly to .mat file from the Simulink model.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by