resample() function in code generation. Any way to use variable Q downsampling factor?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I need to use resample() function to take a variable argument of Q downsampling factor in Simulink. Basically a Simulink fcn block containing this code:
function y = resample_with_VarQ(data,Q)
y=resample(data,1000,Q);
On desktop simulation I can get variable Q to work as argument by specifying it as input to a MATLAB interpreted function, but since I need to generate a C code,my only option is to use the fcn block, obviously it won't compile due to non-constant Q. (i.e. error: the downsample factor Q must be constant)
resample: The upsampling and downsampling factors must be specified as constants. Expressions or variables are allowed if their values do not change.
Any workaround or different approach to address this? Perhaps other block which is capable of doing the same job? ofc it has to be compatible with Simulink coder.
Thanks!
2 commentaires
Pontus Carlsson
le 22 Jan 2018
First sorry for replying to old post, but seems to be exactly my issue.
Currently doing an implementation trying to utilize the resample function in a function block inside a simulink model and receives the same error.
Is there any known workaround to make a non-uniform signal into uniform and resample?
Dimitris Kalogiros
le 23 Juil 2018
I think is impossible to perform "variable-rate resampling" inside Simulink. The reason is that such a block would change its outpout sampling rate during run-time and this is forbidden in simulink.
The only workarround I can think is to implement a virtual resampling, where the resampling block would produce always the same number of output samples per input samples, accompanied by a "control signal" which would indicate the validity of the output samples.
Réponses (1)
Dimitris Kalogiros
le 23 Juil 2018
I think is impossible to perform "variable-rate resampling" inside Simulink. The reason is that such a block would change its outpout sampling rate during run-time and this is forbidden in simulink.
The only workarround I can think is to implement a virtual resampling, where the resampling block would produce always the same number of output samples per input samples, accompanied by a "control signal" which would indicate the validity of the output samples.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!