MATLAB Coder: Runtime Error due to 'Undefined Variable'
Mostrar comentarios más antiguos
I am using MATLAB coder in order to generate a .dll C file from my MATLAB code. Upon the runtime error check I am getting a number of errors for different variables which are all ultimately based on this one:
% Undefined function or variable 'b'. The first assignment to a local variable determines its class.
For this particular error my respective code segment is the following:
% Butterworth
fc = [0.5,1,2,3];
fs = 10;
order = 8;
postbutt = {}; % 1st channel butterworth filtered
filtsigs = zeros(chansize,numchannels); % Butt @ fc = 1Hz
b = zeros(1,order+1); a = zeros(1,order+1);
for f = 1:length(fc)
[b,a] = butter(order, fc(f)/(fs/2));
postbutt{f} = filtfilt(b, a, freq_ch1);
if fc(f) == 1
for chan = 1:numchannels
filtsigs(:,chan) = filtfilt(b, a, freq_ch1);
end
end
end
As it's apparent from the code, I've tried to define and initialize my variables a and b before their actual value assignment in the for loop, in order to avoid the error but that didn't seem to resolve the issue. I've looked around for similar questions in the central but couldn't find an appropriate solution. If anyone has any thoughts on this one it'd be much appreciated!
2 comentarios
KALYAN ACHARJYA
el 9 de Nov. de 2019
chansize?
numchannels?
Vasileios Leivadas
el 9 de Nov. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Algorithm Design Basics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!