Is there a way to deep copy Simulink.SimulationInput object?

I am trying to copy a Simulink.SimulationInput object by doing the following:

By setting the value of variable ‘A’ to 10 after copying Input(1) to Input(2), the value for Input(1) also changes to 10. Why does this happen?

Is there a deep copy method for SimulationInput object?

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

The cause of the observed behavior is that Simulink.Parameter is a handle object so when the second SimulationInput object is assigned to be equal to the first one, both of them refer to the same Simulink.Parameter object.

There are two ways to implement the desired workflow where each SimulationInput object would have independent copies of the Simulink.Parameter object, A:

1. Use ‘Input(2).setVariable(‘A’,Simulink.Parameter(10))’ instead of ‘Input(2).setVariable(‘A.Value’,10)’, it gives the desired outcome:

2.Create Simulink Parameter and SimulationInput object first, then use setVariable:

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.