I have a Simulink model which has user-defined library blocks in it. The values for the variables inside these library blocks are fetched from an ‘m’ script. Basically, I am running the m script to load all the library blocks, then the Model and then run the Simulink model to plot few results. But, I am looking for running the model twice with different values for few variables. Below is the syntax
For count = 1:2;
Load_syntax(library_block)
model = 'model_name';
load_system(model)
sim(model)
plot()
plotyy()
plot()
.
.
& 6 to 8 plots
Variable_name = new value;
end
I am not sure how to merge the plots with the new values over the previous plots, to analyse the results clearly (also plot using a different color). Also, please let me know if we have any other way to achieve this. Please help. Thanks in advance

 採用された回答

Fangjun Jiang
Fangjun Jiang 2016 年 2 月 12 日

0 投票

Since you have multiple plots, you can use figure() to specify which window to plot on. Use hold on if you want to plot the curves together. plot() command has a color option.
figure(1);plot(1:10,'r');
figure(1);hold on; plot(10:-1:1,'g');

1 件のコメント

Nvn
Nvn 2016 年 2 月 15 日
編集済み: Nvn 2016 年 2 月 15 日
Thanks for the answer. with figure(#) now I am able to merge plots together. But, not sure how the color option works with the loop function. It plots with the same color, the second time also. So it is difficult to distinguish between the two.
Is there a way to plot the graph with a different color? I have 2 kinds of graphs. Plotyy and a graph which is already merged(as shown below). When it loops, it plots with the same color. Please help.
plot(torque,'r')
hold on
plot(speed,'g')
plotyy()
hold on
I tried by removing the color code and but it takes the same default color code, twice. So, not sure how to handle this.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTwo y-axis についてさらに検索

質問済み:

Nvn
2016 年 2 月 12 日

編集済み:

Nvn
2016 年 2 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by