Matlab Simulink how to omit signal in some steps - matlab

I'm trying to segment the original signal using the DSP toolbox in Matlab Simulink. I'm using the Time scope to plot it. If the original signal has certain characteristics, I plot it. If not, I omit the signal segment. However, when I omit signals, the time scope stops the simulaiton entirely.
What I want to plot is:
original signal: |seg good1|seg bad1|seg bad2|seg good2|...
filtered signal: |seg good1|seg good2|seg good3|...
How to plot the filtered signal?

Related

How to mark noisy points on from a signal

I have a signal like this
And now i need to mark the points that are considered noisy in the signal. How to do that?
Noisy parts are just as shown in the zoomed in version of the plot and how to mark the noisy points in this signal by using matlab?
Following code might work:
array=abs([0 diff(signal)])
threshold_for_noisy=15
for i=1:size(array,2)
if array(i)>threshold_for_noisy
noisy_ind(i)=1;
else
noisy_ind(i)=0;
end
end
abnormal=zeros(1,size(array,2));
ch_pt=find(noisy_ind==1)
for i=1:2:size(ch_pt,2)-1
abnormal(ch_pt(i):ch_pt(i+1))=1
end
The elements in abnormal will be 1 whenever your signal exceeds the threshold and continues until it reaches back to normal (threshold_for_noisy).
Since the dataset you presented here doesn't have too much variance, simple comparison of past-future values as I suggested in my code will work. But if you have higher variance in your data, you can consider using a built-in function from Signal Processing Toolbox.
See Matlab ischange function documentation

how to seperate a signal into 4 second segment using MATLAB?

I have an ECG signal and I want to separate it 4 second segments. How to do it in MATLAB?
% MATLAB Code
load ('C:\Users\Explorer\Documents\MATLAB\PhysioNet_Database\Malignant_Ventricular_Ectopy_Database\418m.mat');
signal=val(1,:);
plot(signal); xlabel('Time'); ylabel('Voltage');
418m.mat
The signal is downloaded from website of PhysioNet and is of MIT BIH Malignant_Ventricular_Ectopy_Database.
There are two signal in 418m.mat. I just want to separate first one signal.
Also, there is a function buffer() in MATLAB but it is only for equally spaced in time. I don't know whether this signal is equally spaced in time or not.

Strengthening the low amplitude signal using Matlab WITHOUT changing the original shape of the signal

I have a problem in signal processing with Matlab.
I would like to analyze some signal using Matlab but there is a huge difference between the amplitude of signals.
The problem is that the shape of the signal in low amplitude is similar to the shape of the signal in high amplitude. but to analyse the signal, I have to have same range amplitude signal.
how can I have that without destroying the shape and properties of the signal?
Sorry I couldn't send an example plot to clear that.
Something like:
signal1;
signal2;
signal1=(signal1- min(signal1(:))/(max(signal1(:))-min(signal1(:)))
signal2=(signal2- min(signal2(:))/(max(signal2(:))-min(signal2(:)))
% Now both signals are 0-1 range
Without more information this is all what we can offer!

Continuos Signal to MATLAB Function in Simulink

How can I introduce a continuos signal to a MATLAB Function block so I can get a continuos output.
My MATLAB Function block will be this:
function y = fcn(u)
y = 2*exp(-u);
So I can get a negative exponential, this because I need a control voltage source with a negative exponential signal. I need to introduce a controlled voltage source a exponential signal, is there other way?
Thanks
First of all, you don't need a MATLAB function to do that: take your input signal, multiply it by -1 with a Gain block, then use a Math Function block set to exp, and finally another Gain block to multiply it by 2.
Second, your input signal can be whatever you want. For example, you can use a Sine Wave block, or choose whatever block you want from the Sources library. If you leave the Sample Time parameter to 0, you will have a "continuous" signal (in the Simulink sense of the word), see Specify Sample Time in the documentation for more details. You can also use your own data from the MATLAB workspace using a From Workspace block.

how to show a modulate signal in Matlab simulink

i want to show the signal modulate in simulink but i don't know how to make it
The Spectrum Scope calculates the FFT of the input signal.
In your model you are trying to take the fft of the fft.
(Although you aren't quite doing that as the input to the FFT block needs to be buffered so that the FFT has a vector of data over which to calculate the FFT.)
Remove your FFT and Abs blocks and feed the signal directly into the Spectrum Scope.
Use the block's dialog to set the buffer and FFT length that you want to use.
Phil.