resample() function in code generation. Any way to use variable Q downsampling factor?
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Pontus Carlsson
2018 年 1 月 22 日
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
2018 年 7 月 23 日
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.
回答 (1 件)
Dimitris Kalogiros
2018 年 7 月 23 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!