Can I use knobs to control several elements from the same injected struct?

I am accessing an injected struct that has several elements I want to use individual knobs to control through a mask but I am not seeing the elements when I try to connect the knobs to the constant block. Can anyone assist me?

4 Comments

Hi Ayodeji,
Can you provide more information about what blocks you are using and how they are connected?
I have several constants that are initialized through a mask struct. These constants feed into a bus assignment element.
Hi Ayodeji,
I would like to confirm that I understand the problem.
You have a subsystem in your model lets say "subs1". subs1 contains constant blocks lets say "c1", "c2" and "c3". In the same subsystem you have the knobs that will be used control these constant blocks.
Is that correct?
Yes, that is correct. Were you able to view the image I attached to my initial post?

Sign in to comment.

Answers (1)

Yes, you can use knobs to control several elements from the same injected struct in Simulink.
You can follow the below steps:
  • Ensure that the struct is accessible in your Simulink model. If it is defined in the workspace, make sure it is loaded before running the simulation.
  • For each element you want to control, use a Constant block.
  • Set the Constant block's value to reference the specific struct element.
  • Each knob should be connected to a Constant block.
  • Double-click the knob and set its parameter to control the value of the corresponding Constant block.
  • Ensure that the mask parameters are correctly set to allow access to the struct elements.
  • Use the "get_param" and "set_param" functions to dynamically update the Constant blocks with the knob values.
  • If you see "Unable to find elements to connect in selection," ensure that the path to the struct element is correct.
  • After making changes, update the Simulink model by clicking on "Update Diagram" or press "Ctrl+D".

Categories

Products

Release

R2023b

Asked:

on 23 Jan 2025

Answered:

on 6 Feb 2025

Community Treasure Hunt

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

Start Hunting!