how to define initial dimention to variable that has various dimention in matlab function block simulink?
4 次查看(过去 30 天)
显示 更早的评论
I define matlab function block that compute continuos wavelet transfrom(CWT) in simulink and have problem to initialize output of cwt, because the wavelet coefficients have various dimention in each time step.
- how should i define initial value of cwt output?
- and how should i write that every 0.5 second pass, compute cwt?(not in all time steps)
my FCN code:
function [c,f]=cwtendpadding(x)
coder.extrinsic('cwt')
c=zeros(401)+0i;
f=nan(200,1);
global x_hist x_ind
x_hist(x_ind)=x;
x_ind = x_ind+1;
if x_ind>=100
[c,f]=cwt(x_hist(1:x_ind-1),'amor',1000,'ExtendSignal',false);
end
end
error: Size mismatch for MATLAB expression 'c'. Expected = 401x401 Actual = 38x99
0 个评论
回答(1 个)
Shree Harsha Kodi
2023-6-30
To initialize the output of the Continuous Wavelet Transform (CWT) block in Simulink, you can use a constant block that matches the expected dimensions of the wavelet coefficients. Since the wavelet coefficients have varying dimensions at each time step, you can set the initial value to an empty matrix or a zero matrix.
Regarding computing the CWT every 0.5 seconds, you can use the Sample Time parameter in Simulink to control the timing of the CWT computation
Go through the following documentation for a better understanding:
1)https://in.mathworks.com/help/wavelet/ref/cwt.html
2)https://in.mathworks.com/help/simulink/ug/model-configuration-parameters.html
3)https://in.mathworks.com/help/simulink/ug/block-libraries.html
1 个评论
NIKOLAY YAKOVENKO
2023-11-6
Well , usage of coder.extrinsic('cwt') points to the fact that you can create such matlab function block in Simulink (CWT), and it will work, but cannot generate production quality code using embedded coder? That is what happened to me.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!