Info

This question is closed. Reopen it to edit or answer.

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

2 views (last 30 days)
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?

Answers (0)

This question is closed.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!