Size mismatch between graphical signal and actual source signal
7 views (last 30 days)
Show older comments
I have a Simulink model that is giving me the following errors (multiple of the same):
"Unable to upload data to <source block name> due to a size mismatch between the graphical signal <dest block name> and the actual source signal. Insert a Signal Conversion block, or use the Simulation Data Inspector to view signal data."
I'm a bit confused about this error, as I can turn on the Signal Dimensions overlay and see that the signals I want to display are coming out of the previous block as a 13x1 vector, I use a demux with 13 ports, and I connect the ports I want to display up to display blocks after breaking out from the demux, one by one.
The source of the data is a custom S-function, created with the S-function builder, that parses some data coming in on serial from a GPS device. If I route the first output port of the S-function to a MAT file instead of the demux block, I am able to download the data from the Raspberry Pi and see the data, all valid and properly formatted.
The suggested solution of adding the Signal Conversion block does not seem to work. Can anyone explain this error? The error message does not contain enough information for me to investigate the root cause of the problem, and the difference in behavior between logging the signal to a MAT file vs. breaking out and displaying it has me stumped. Thanks!
0 Comments
Answers (1)
Nehemiae
on 7 Mar 2023
Hello,
In order to get the data output from the S-function block, the “Dimensions” and “SamplingMode” properties of the output port must be set as shown below. I have assumed a sample output data array of size 13x1 that is then broken out by the demux for each display block.
function data_out(block)
setup(block);
end
function setup(block)
block.NumDialogPrms = 0;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 1;
%% Setup port properties
block.OutputPort(1).Dimensions = [13 1];
block.OutputPort(1).SamplingMode = 'Sample';
%% Set block sample time
block.SampleTimes = [1 0];
%% Set the block simStateCompliance to default (i.e., same as a built-in block)
block.SimStateCompliance = 'DefaultSimState';
%% Register methods
block.RegBlockMethod('Outputs', @Output);
end
function Output(block)
block.OutputPort(1).Data = [0.8003, 0.1419, 0.4218, 0.9157, 0.7922, 0.9595, 0.6557, 0.0357, 0.8491, 0.9340, 0.6787, 0.7577, 0.7431]';
end
The corresponding Simulink model is shown below.
The documentation on S-functions (https://www.mathworks.com/help/simulink/slref/level2matlabsfunction.html) can help understand the above code.
0 Comments
See Also
Categories
Find more on Run on Target Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!