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 Exchange에서 Two 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