Array iteration using a for loop in stateflow

조회 수: 5 (최근 30일)
Denizhan AKINCI
Denizhan AKINCI 2024년 3월 19일
답변: Yash 2024년 3월 26일
Hello everyone, I am trying to import the trajectories of my robot in order to simulate the robot dynamically. My goal is to simulate the robot during every trajectory consecutively and to save the dynamic results, torques etc. the problem is I have a big amount of trajectory (44608 different trajectories for a 6 axis robot so 44608x6 matrix of waypoints) Also each trajectory's timepoints are like this 0:0.1:4 (41 step) and timepoints matrix is 1x44608. What I want is to utilize stateflow in order to run the simulation for each row of the waypoints matrix and each 41 row of the time matrix. I tried using for each loop but It doesn't work with minimum jerk polynomial trajectory block that interpolates the qd and qdd. I am open to suggestions !

채택된 답변

Yash
Yash 2024년 3월 26일
Given the complexity and the size of your data (44608 different trajectories for a 6-axis robot), a direct for loop approach might not be the most efficient or feasible solution, especially if you're dealing with Simulink models which are generally designed to run simulations over time rather than iterate through loops like traditional programming scripts. Instead of trying to loop through trajectories directly in Simulink or Stateflow, use a MATLAB script to manage this. The script can load each trajectory, set it as a parameter in the Simulink model, and then run the simulation.
Given the large number of simulations, consider using MATLAB's parallel processing capabilities to run multiple simulations simultaneously. This can significantly reduce the overall computation time. Remember to use parfor carefully, ensuring your MATLAB session has access to multiple cores and that there's no data dependency between iterations that could cause issues.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stateflow에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by