Variables keep overwriting when i change the name

6 次查看(过去 30 天)
I am trying to obtain 5 current values and 5 voltage values on my simulink project. The outputs of both are generated with a 'To Workspace' block. When i run simulink i get my variables 'current' and 'voltage' without a problem. However, when i change the circuit i change the variable names to 'current1' and 'voltage1' and when i run simulink. The new variables overwrite the first ones. Im trying to get values like current, current1, current2 etc but matlab only saves the most recent values. Does anyone know how to fix this?
  1 个评论
Daniel M
Daniel M 2019-10-19
Are you saying that the output of current1 has overwritten the value of current? As in, both variables continue to exist in the workspace, but they have the same value?
Or do you mean that only current1 exists and current is deleted?

请先登录,再进行评论。

回答(1 个)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019-10-19
Hi,
You would need to create a small loop to run your simulink model via sim() command and every iteration results can be saved and not overwritten.
Here is very generic pseudo-code.
IN = [1.5, 2.2, 3.23, 4.1, 5.78, 6.12]; % Different values
for ii=1:numel(IN)
MY_var = b(ii); % This is the variable (constant) name that is in your Simulink model. It can be also series...
y(:,ii)=sim('SIM_MAT.slx');
end
Good luck.

类别

Help CenterFile Exchange 中查找有关 Switches and Breakers 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by