Question on Simulink Matlab Function
40 views (last 30 days)
Show older comments
Hello Everyone,
I'd like to ask something about the MATLAB Function in Simulink.
My project is try to use the MATLAB function to create a bitstream of the data (As frame) with variable output size depend on the input.
Here is my question.
1) Possible to set the MATLAB function output as dynamic variable size depend on the output of the function?
Example,
1st frame is generated data size = [200x1], After first frame output size should be 200x1
2nd frame is generated data size = [196x1], After second frame output size should be 196x1
2) The output from MATLAB Function must connect to the DBPSK modulation block (as below diagram)![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762959/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762959/image.png)
But I got this error.
Error:Simulink cannot propagate the variable-size mode from the 'Output Port 1' of 'SigfoxTX/DBPSK Modulator Baseband/In1' to the 'Input Port 1' of 'SigfoxTX/DBPSK Modulator Baseband/M-DPSK Modulator Baseband'. This input port expects a fixed-size mode. The variable-size mode originates from 'SigfoxTX/MATLAB Function'. Examine the configurations of 'SigfoxTX/DBPSK Modulator Baseband/M-DPSK Modulator Baseband' for one of the following scenarios: 1) the block does not support variable-size signals; 2) the block supports variable-size signals but needs to be configured for them.
Below is original setting on Model Exploer.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762964/image.png)
When I uncheked the Variable size, I got this error instead.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762969/image.png)
Are there any way to fix this issue?
Thank you in advance.
PS. I also attached the simulink model for your reference.
Best Regards,
Fumihiko Sato
0 Comments
Answers (2)
Aravind
on 30 Aug 2024 at 11:00
The “DBPSK modulator” block in Simulink, does not support variable-size input signals. Hence, you are receiving an error regarding this, when your “MATLAB function” block is outputting a variable-size signal. More information on which Simulink blocks in the Communications Toolbox support variable-size signals, run the “showcommblockdatatypetable” function from the MATLAB Command line.
0 Comments
praguna manvi
on 30 Aug 2024 at 13:32
MATLAB Function block supports variable-size arrays for input and output types, it can be configured in Model Explorer, you can know refer more about its block properties here:
However, DBPSK Modulator Baseband doesn’t support variable-sized arrays you can confirm it view the supported data types by running:
showcommblockdatatypetable
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1763344/image.png)
A possible workaround fix to resolve this issue is to either truncate or pad the output of the MATLAB Function block to a fixed size.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!