We are using for-iterator loop, display is showing correct result but while analyzing graph we got to know it is having spikes.

1 次查看(过去 30 天)
We have having problem in implementation of for loop, the out of each element of for loop is having spike. Let's say that the output is to be retained at 49 but it's having spike.

回答(1 个)

Harsh Sanghai
Harsh Sanghai 2022-10-25
As per my understanding the "assignment block" copies the input vector and update it in each step due to which these spikes occur. Use "MATLAB function block" instead of assignment block to assign the vector and remove the spikes.
Refer to the following code of the MATLAB function block:
function y = fcn(u, data, idx)
persistent temp
if isempty(temp)
temp = u;
end
temp(idx) = data;
y = temp;

类别

Help CenterFile Exchange 中查找有关 Multibody Modeling 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by