0
votes

I have a system build in simulink and the output of the system. The output has valuable data points in the peaks/spikes and other, not valuable data points at magnitude of 70.

What I am struggling to achieve is the output signal, consisting only of the valuable data points connected with each other straightforward(basically, these are the datapoints I need).

I attached the picture with the original output signal from the scope and the one I built from it in matlab after extracting the original as a structure with time into workspace.

Output in the scope

After processing the signal from the scope in matlab

Here is the code I use to process and plot it:

ab = [];
a = [];
for i=1:numel(Tc.signals.values)
    if Tc.signals.values(i)<70
        ab = [ab;Tc.signals.values(i)];
        a = [a;Tc.time(i)];
    end
end
plot(a, ab, '-k', 'LineWidth', 1);
grid on;

My question is what blocks and how should I add so that the output is transformed during the simulation into what I ploted outside the simulation from matlab? I really have difficulties finding a good solution... :(

Thank you very much in advance!

1
If I understand correctly your question, than I think you can't. The slope of your interpolation depends on the next spike, and you (probably) don't know its magnitude in advance. That graph can be built only in postprocessing.Matteo Ragni
there is no data in the slopes, there are only points on 'top' of the spikes and points at 70... Idealy I just want a signal over the same time consisting of connected spikes points though... The spikes are creaded with a use of delay in integrator reset loop (i.e. I do not eliminate the signal for the delay time... a bit difficult to explain tbh).. So the point is that I can 'say' "this is a spike" during the simulation using another signal..Serchy
*signals.. time and magnitudeSerchy
This can't be done. As per Matteo's comment: Assume the current time is 1 (or 10 or 50) time periods after the first spike. Since Simulink doesn't know when, or what value, the second spike will have, how can it draw a (correctly sloped) line from the first spike to the current time period?Phil Goddard

1 Answers

0
votes

Code the if statement you show using a switch block, trigger using a logical <70, if false loop last output back using zero hold, you will still get output each time step but it will just be the last point you caught. I assume this is a discrete sim with output set to hold.