Skip to content
Snippets Groups Projects
Commit 3e30ae92 authored by Wang Shiwen's avatar Wang Shiwen
Browse files

Delete read_sim_data.m

parent 227eaaa7
No related branches found
No related tags found
No related merge requests found
function [value, t, name_list] = read_sim_data()
% read the data get by simulink and plot all signals
% value is the 6 signals, t is the time axis,
% name_list is the name of signals of each line
% you can get them by [value, t, name_list] = read_sim_data();
% and plot the desired signals
% set the work folder
load_system("siso")
out = sim("siso");
name_list = fieldnames(out.simout);
for i = 1:length(name_list)
k = name_list(i);
key = k{1};
if strcmp(key, 'Activator')
tA = out.simout.(key).time;
A = out.simout.(key).data;
m = 1;
for j = 1:length(value(1,:))
if t(j) == tA(m)
value(i,j) = A(m);
m = m + 1;
else
value(i,j) = value(i, j-1);
end
end
else
t = out.simout.(key).time;
value(i,:) = out.simout.(key).data;
end
plot(t, value)
hold on
end
grid on
legend(name_list)
title("Simple simulation")
xlabel("Time/s")
ylabel('Concentration')
hold off
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment