이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
What is the best practice for passing data to use for visualization?
조회 수: 1(최근 30일)
표시 이전 댓글
sloppydisk 2019년 1월 21일
마감: MATLAB Answer Bot 2021년 8월 20일
What is the best practice for passing variables to a function for visualization?
I am working on a simulation of a flexible mechanism. Currently I have my script set up to run roughly in 4 files:
- input_params.m defines parameters for a specific problem, this file in turn calls ode_sim.m with these parameters as a struct.
- ode_sim.m finds output variables like y_out, u_out, t_out etc. from an ode simulation, this file then calls kinematics.m and visualize.m
- kinematics.m constructs the other relevant output variables like the material points p_mat from y_out, u_out etc. as arguments
- visualize.m then takes a bunch of arguments y_out, u_out, p_mat to visualize them in plots and animations
Now when I have finished my simulation I would like to be able to change the visualization only and rerun it without redoing the simulation, currently this is not possible, because the input variables for visualize.m are passed from the workspace of the function ode_sim.m, which is not accessible from the command window. To change my code to have that possibility there are a bunch of options, two of which are:
- Save the data in a .mat file and load the variables from that in visualize.m
- Save the data in the workspace of input_params.m and run visualize.m there (this would work only if ode_sim.m was run earlier this session)
Which of these would be the most accurate way of structuring my code or do you know of a better way?
댓글 수: 0
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!