![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1168363/image.png)
We are using for-iterator loop, display is showing correct result but while analyzing graph we got to know it is having spikes.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1164213/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1164218/image.png)
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.
0 comentarios
Respuestas (1)
Harsh Sanghai
el 25 de Oct. de 2022
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1168363/image.png)
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;
0 comentarios
Ver también
Categorías
Más información sobre Multibody Modeling en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!