"Output argument 'labelVals' (and possibly others) not assigned a value" in SignalLabeler
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Githin George
2023 年 10 月 25 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!