48 lines
878 B
Matlab
48 lines
878 B
Matlab
tg = slrt;
|
|
|
|
%% TODO - Build this application if updated
|
|
|
|
%%
|
|
if tg.Connected == "Yes"
|
|
if tg.Status == "stopped"
|
|
%% Load the application
|
|
tg.load('test');
|
|
|
|
%% Run the application
|
|
tg.start;
|
|
pause(10);
|
|
tg.stop;
|
|
|
|
%% Load the data
|
|
f = SimulinkRealTime.openFTP(tg);
|
|
mget(f, 'data/data_001.dat');
|
|
close(f);
|
|
end
|
|
end
|
|
|
|
%% Convert the Data
|
|
data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data;
|
|
|
|
t = data(:, end);
|
|
x1 = data(:, 1);
|
|
x2 = data(:, 2);
|
|
|
|
save('mat/data_003.mat', 't', 'x1', 'x2');
|
|
|
|
%% Plot the data
|
|
figure;
|
|
hold on;
|
|
plot(t, x1);
|
|
plot(t, x2);
|
|
hold off
|
|
xlabel('Time [s]');
|
|
ylabel('Voltage [V]');
|
|
|
|
%% Compute the PSD
|
|
dt = t(2)-t(1);
|
|
|
|
window_L = ceil(length(x1)/10);
|
|
window_han = .5*(1 - cos(2*pi*(1:window_L)'/(window_L+1)));
|
|
|
|
[pxx, f] = pwelch(x1, window_han, 0, [], 1/dt);
|