Plotting 2 scripts on 1 graph

5 visualizzazioni (ultimi 30 giorni)
Takura Nyatsuro
Takura Nyatsuro il 22 Mar 2023
Risposto: Jon il 22 Mar 2023
i have made 2 codes which solve a problem analytically and numeriacally and now i am trying to dispay this data on one graph. I there a way i can pull data from one script son i can plot all my data in one graph?
Thank you

Risposte (1)

Jon
Jon il 22 Mar 2023
The results of running scripts are saved in the local workspace.
So lets say that inside of script one you calcualate values of variables named t1 and x1, and inside of script two you calculate values of variables named t2 and x2
Then you would run script one, then run script two and then plot using
figure % make a new figure
plot(t1,x1,t2,x2)
You could also make one master script to run the two other scripts so something like
% run first script (produces t1 and x1)
script1
% run second script (produces t2 and x2)
script2
% plot results
figure
plot(t1,x1,t2,x2)
You may also want to consider using functions for the two different analyses and then you can avoid hardcoding the names of the variables output by each script

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by