sim command clears the workspace in a for loop
Afficher commentaires plus anciens
Hi I have a simulink model. There are two blocks in it which need to be updated. So I use "sim command" in a for loop in order to get data from previous step for the next one. But it seems that sim command clears the workspace in each iteration. So there is nothing in workspace. I tried
options = simset('SrcWorkspace','current', 'DstWorkspace', 'current');
but it wasn't helpful. I appreciate it if you could help me. Thanks. This is the code I use to run the model.
clc
clear all
T=100;
q=zeros(T,3);
m=zeros(T,2);
%M=tf([0.5],[1 1]);
%Q=tf([1 1],[2 1]);
for i=1:T
Q = tf([q(i,1) q(i,2)],[1 q(i,3)]);
M = tf([m(i,1)],[1 m(i,2)]);
options = simset('SrcWorkspace','current', 'DstWorkspace', 'current');
sim('adp_imc_1',[i i+1],options)
end
3 commentaires
Omur Bas
le 2 Oct 2017
The sim command does not clear the workspace. It might be overwriting some variables depending on your model configuration. Try to use sim with output arguments (look up the documentation for syntax) and you can get an idea of what's going wrong.
Réponses (0)
Catégories
En savoir plus sur Sources dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!