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.
  1. how should i define initial value of cwt output?
  2. 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

답변 (1개)

Shree Harsha Kodi
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
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 CenterFile Exchange에서 Continuous Wavelet Transforms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by