Plotting 2 scripts on 1 graph

조회 수: 3 (최근 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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by