How can I connect two seperate Simulink models?
Show older comments
I have two Simulink models (Matlab 7.11 and Matlab 6.5) and I want them co-simulate. There is no way in merging them in one Matlab version (given boundary condition). A brief desription of the situation I want to create: model one gets an initialization vector, does some calculations, give the results to model 2 and waits. The latter model waits until it gets the data from model 1, does some calculation as well, gives the solutions back to model one and so on. This should be repeated for every time step. Both Matlab applications will run on the same machine. I have no idea how to realize this. I tried something with UDP, but I found out there are no UDP toolboxes in Matlab 6.5. I don't know how to make the models wait for each other. I hope someone will have some inspiring ideas for me :)
Thank you in advance! :)
Answers (2)
Kaustubha Govind
on 25 Oct 2012
0 votes
Why not use the Model block to reference each model? You can connect them in a third top-level model.
3 Comments
Stefan
on 26 Oct 2012
Kaustubha Govind
on 26 Oct 2012
No, but can you not load the model from 6.5 in 7.1?
Stefan
on 26 Oct 2012
Azzi Abdelmalek
on 26 Oct 2012
Edited: Azzi Abdelmalek
on 26 Oct 2012
Use two scripts in each session of matlab. for example script1
x=load('comunicat')
if x.test==1
sim('model1')
test=0
save cmunicat test
end
while test==0
pause(10)
x=load('comunicat')
test=x.test
end
%
sim('model1') %
...
use the same with script2. The mat file comunicat contain one logical variable. It says which model will run
12 Comments
Stefan
on 26 Oct 2012
Azzi Abdelmalek
on 26 Oct 2012
Edited: Azzi Abdelmalek
on 26 Oct 2012
- suppose ts is your sample time, set time simulation to ts
- lunch your two m files in your 2 sessions
- in file1
test=0
for k=1:1000
while test==0
pause(10)
x=load('comunicat')
%file 1 waits until test=1(when file2 finishs simulation)
test=x.test
end
sim('model1') % use data from model 2, load file or...
test=0
save comunicat test % will trigger model 2
end
Stefan
on 26 Oct 2012
Azzi Abdelmalek
on 26 Oct 2012
pause(10)
% will wait 10 secondes before checking a mat file
Azzi Abdelmalek
on 26 Oct 2012
Edited: Azzi Abdelmalek
on 26 Oct 2012
But the question is, why make it dificcult when you can work with one model using 2 triggered subsystems
Azzi Abdelmalek
on 26 Oct 2012
you can convert your model(matlab 6.5) to (matlab 7.11), have you tried to do it?
Stefan
on 26 Oct 2012
Azzi Abdelmalek
on 26 Oct 2012
Just open it under matlab 7.11, If you've tried to do it, is there error messages
Stefan
on 26 Oct 2012
Stefan
on 26 Oct 2012
Categories
Find more on Test Model Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!