- Store the data to be transmitted as part of the CAN message in a variable in the base workspace. The data should be in a format that the "From Workspace" block supports.
- Add "From Workspace" and specify the "message_ts" variable that is to be read from the workspace.
- Connect the "From Workspace" block to the "CAN pack".
- Specify the message name, CAN identifier, length etc. of the message in the block parameters dialog box of the "CAN Pack" block. The length specified should be equal to the number of data elements.
- "From Workspace" block: https://www.mathworks.com/help/releases/R2023b/simulink/slref/fromworkspace.html
- "CAN Pack" block: https://www.mathworks.com/help/releases/R2023b/vnt/ug/canpack.html
- "can.Message" object properties: https://www.mathworks.com/help/releases/R2023b/vnt/ug/can.message-properties.html