フィルターのクリア

Plotting 2 scripts on 1 graph

4 ビュー (過去 30 日間)
Takura Nyatsuro
Takura Nyatsuro 2023 年 3 月 22 日
回答済み: Jon 2023 年 3 月 22 日
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

回答 (1 件)

Jon
Jon 2023 年 3 月 22 日
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

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by