Info

この質問は閉じられています。 編集または回答するには再度開いてください。

What is the best practice for passing data to use for visualization?

1 回表示 (過去 30 日間)
sloppydisk
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 件)

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by