How do I compare two simulation files?

1 回表示 (過去 30 日間)
Ali AlMuslih
Ali AlMuslih 2022 年 11 月 20 日
回答済み: William Rose 2022 年 11 月 21 日
I have two files, each file contains one simulation, and each simulation contains 5 output results. I want to compare them in one plot for each result.
  1 件のコメント
William Rose
William Rose 2022 年 11 月 20 日
@Ali AlMuslih, load both files and plot all 10 results on one plot, with different colors and line types. If the 5 results in file 1 and the five results in file 2 are "pairs" in some sense, then you might want to use the same 5 colors twice, but use solid lines for the file 1 results, and dashed lines for the file 2 results.

サインインしてコメントする。

回答 (1 件)

William Rose
William Rose 2022 年 11 月 21 日
Here is an example of what I mean. I am attaching two files of simulated data, with 5 records , plus a column for time, in each file.
data1=load('results1.txt');
data2=load('results2.txt');
t1=data1(:,1); %time column from file 1
x1=data1(:,2:6); %5 columns of results from file 1
t2=data2(:,1); %time column from file 2
x2=data2(:,2:6); %5 columns of results from file 2
%Plot data
%plot(t1,x1(:,1),'-rx',t1,x1(:,2),'-g+',t1,x1(:,3),'-bo',t1,x1(:,4),'-c^',t1,x1(:,5),'-md')
plot(t1,x1(:,1),'-r',t1,x1(:,2),'-g',t1,x1(:,3),'-b',t1,x1(:,4),'-c',t1,x1(:,5),'-m')
grid on; hold on;
%plot(t2,x2(:,1),'--rx',t2,x2(:,2),'--g+',t2,x2(:,3),'--bo',t2,x2(:,4),'--c^',t2,x2(:,5),'--md')
plot(t2,x2(:,1),'--r',t2,x2(:,2),'--g',t2,x2(:,3),'--b',t2,x2(:,4),'--c',t2,x2(:,5),'--m')
legend('1A','1B','1C','1D','1E','2A','2B','2C','2D','2E')
Try it.

カテゴリ

Help Center および File ExchangeView and Analyze Simulation Results についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by