Effacer les filtres
Effacer les filtres

how to define initial dimention to variable that has various dimention in matlab function block simulink?

1 vue (au cours des 30 derniers jours)
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

Réponses (1)

Shree Harsha Kodi
Shree Harsha Kodi le 30 Juin 2023
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 commentaire
NIKOLAY YAKOVENKO
NIKOLAY YAKOVENKO le 6 Nov 2023
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Continuous Wavelet Transforms dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by