필터 지우기
필터 지우기

sim command clears the workspace in a for loop

조회 수: 1 (최근 30일)
Mohammad
Mohammad 2017년 9월 30일
편집: Mohammad 2017년 10월 2일
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
Mohammad
Mohammad 2017년 10월 2일
편집: Mohammad 2017년 10월 2일
@Omur Bas : Thanks for your comment but I think it's the sim command. because even when it's used out of the for loop for an interval like [1 2]and you want to do the simulation again without any "clear all command" the data related to the [1 2] is cleared. and we have the new data related to the new interval.
@ Stephen Cobeldick: I already used the piece of code mentioned in these posts. Nothing happened!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by