how to use segmentSignals() in Deep learning

Hello
I want to use a deep learning Example in matlab, which is in beloew link:
In the example, function segmentSignals() is not existing. I have tried with matlab 2020a and tried it online in which both sends me an error that this funcrion is not defined.
would you please provide me the fucntion?
Best Regards
Amin

5 Comments

I am getting the same error.
Did you manage to resolve this issue?
Im pass this functinon but it works !
function [signalsOut, labelsOut] = segmentSignals(signalsIn,labelsIn)
%SEGMENTSIGNALS makes all signals in the input array 9000 samples long
% Copyright 2017 The MathWorks, Inc.
targetLength = 9000;
signalsOut = {};
labelsOut = {};
for idx = 1:numel(signalsIn)
x = signalsIn{idx};
y = labelsIn(idx);
% Ensure column vector
x = x(:);
% Compute the number of targetLength-sample chunks in the signal
numSigs = floor(length(x)/targetLength);
if numSigs == 0
continue;
end
% Truncate to a multiple of targetLength
x = x(1:numSigs*targetLength);
% Create a matrix with as many columns as targetLength signals
M = reshape(x,targetLength,numSigs);
% Repeat the label numSigs times
y = repmat(y,[numSigs,1]);
% Vertically concatenate into cell arrays
signalsOut = [signalsOut; mat2cell(M.',ones(numSigs,1))]; %#ok<AGROW>
labelsOut = [labelsOut; cellstr(y)]; %#ok<AGROW>
end
labelsOut = categorical(labelsOut);
end
any body solve this prblem please???????
Thank you @Fan Peng, this worked wonderfully

Sign in to comment.

Answers (0)

Categories

Asked:

on 27 Oct 2020

Commented:

on 10 Dec 2022

Community Treasure Hunt

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

Start Hunting!