how to define initial dimention to variable that has various dimention in matlab function block simulink?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Shree Harsha Kodi
el 30 de Jun. de 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 comentario
NIKOLAY YAKOVENKO
el 6 de Nov. de 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.
Ver también
Categorías
Más información sobre Continuous Wavelet Transforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!