Question
I am working on traffic simulation in Simulink. trying to show movement using coordinate system i am trying to makeup. I am facing following problem in that. For now just consider x axis For translation of car on x axis tried using FOR loop in embedded MATLAB function but it doesn`t give values of intermediate iterations. When For Subsytem is used it gives out array on N size if N iterations are done. But the desired Output should be scalar so as to feed it to VRsignal Expander(consider set to 1) now How can i send values from that N sized array one by one by using another for loop ? n get the same problem again well i think i m applying wrong Logic to this problem If there is totally different and simpler way out to solve the problem of sending data continuously. i`ll appreciate the help.
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 26, 2026
here's a simple way, insert a Constant block in your model, start the simulation from 0 to inf
Now in one m file put a loop with this line of code inside
set_param('MyModelName/Constant','Value',num2str(DataToModel))
Change MyModelName with the name of your model file and DataToModel with the data you want to send, here's a simple example
Make a model with the Constant connected to a Display, run it to inf
Put the next code in one m file and run it
for a=1:0.1:10
set_param('MyModelName/Constant','Value',num2str(a)) %send a to the model
pause(1) %pause for 1 second
end
Now see the value in the display changing
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related simulink Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →