"Output argument 'labelVals' (and possibly others) not assigned a value" in SignalLabeler
Ältere Kommentare anzeigen
Hello all and thank you in advance!
I am trying to create a custom labeling function for signal labeler and have tested it as a normal Matlab command and it works there.
However, as soon as I try to run it in SignalLabeler I get the above mentioned error message.
I have attached the code below and would be very grateful for any suggestions!
function [labelVals,labelLocs] = FindN2bP3Complex(x,freq,varargin)
%parentLabelVal,parentLabelLoc,varargin)
% Only applicable if epoch size is 1sec
num = 1;
for i = 1:(size(x,1)/freq)
localmax = islocalmax(x(num:num+(freq-1)));
localmin = islocalmin(x(num:num+(freq-1)));
xMax = find(localmax==1);
yMax = x(localmax);
xMin = find(localmin==1);
yMin = x(localmin);
if size(xMax,1) <= size(xMin,1)
countextreme = size(xMax,1);
else
countextreme = size(xMin,1);
end
count = 1;
for h = 1:countextreme
linvec = [(xMin(count)-xMax(count)) (yMin(count)-yMax(count))];
xrow = xMin(count);
xcol = xMax(count);
if x(xrow:xcol) == linvec(count:end)
else
labelLocs(count,1)=xMin(count);
labelLocs(count,2)=xMax(count);
labelVals(count,1)="N2bP3Complex";
end
count = count+1;
end
num = num+(freq-1);
end
Antworten (1)
Githin George
am 25 Okt. 2023
Hello,
I understand you are getting the error "Output argument 'labelVals' (and possibly others) not assigned a value" in Signal Labeler App when trying to import your custom labelling function.
Looking at the code provided and the error message, it is most likely due to ‘labelVals’ and ‘labelLocs’ not being assigned a value outside of the else condition and hence MATLAB is throwing the error.
In addition, the function signature is also not matching with the recommended signature for a custom labeling function which would be as follows.
function [labelVals,labelLocs] = FindN2bP3Complex(x,t,parentLabelVal,parentLabelLoc,varargin)
% This is a template for creating a custom function for automated labeling
%
% x is a matrix where each column contains data corresponding to a
% channel. If the channels have different lengths, then x is a cell array
% of column vectors.
%
% t is a matrix where each column contains time corresponding to a
% channel. If the channels have different lengths, then t is a cell array
% of column vectors.
%
% parentLabelVal is the parent label value associated with the output
% sublabel or empty when output is not a sublabel.
% parentLabelLoc contains an empty vector when the parent label is an
% attribute, a vector of ROI limits when parent label is an ROI or a point
% location when parent label is a point.
%
% labelVals must be a column vector with numeric, logical or string output
% values.
% labelLocs must be an empty vector when output labels are attributes, a
% two column matrix of ROI limits when output labels are ROIs, or a column
% vector of point locations when output labels are points.
end
The following link provides an end-to-end example of using custom labeling functions for Signal Labeler App.
I hope this helps resolve the issue.
6 Kommentare
Walter Roberson
am 25 Okt. 2023
if the number of rows of x is less than freq then the output variable would not be defined.
Michel
am 25 Okt. 2023
Githin George
am 25 Okt. 2023
"Could you please share a mat file with the signal data you are using so that I can verify at my end?"
Walter Roberson
am 25 Okt. 2023
A signal segment that is sorted ascending or decreasing has no local minimum or maximum, which your code does not deal with.
Michel
am 25 Okt. 2023
Michel
am 27 Okt. 2023
Kategorien
Mehr zu Descriptive Statistics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!