How can i delete zeros of a Simulation Output?

1 次查看(过去 30 天)
I have a list of values coming from a Simulink model.
I want to ignore the rows that are aproximately 0. I tried with the following code, but the problem is that i keep getting the same output (with 0 instead of NaN). What should I do?
for i=1:1:length(SimOut.System1_UPF_IQ.signals.values(:,1))
if (abs(SimOut.System1_UPF_IQ.signals.values(i,3)) <= 1E-5)
SimOut.System1_UPF_IQ.signals.values(i,2) = nan; SimOut.System1_UPF_IQ.signals.values(i,3) = nan;
else
end
end

回答(1 个)

Rebeka
Rebeka 2022-7-18
a=[1 0 9 7; 3 4 5 6; 0 5 0 0; 2 3 4 5; 1 1 1 1];
x=size(a);
m=x(1);
n=x(2);
for i=1:m
for j=1:n
if a(i,j)==0
a(i,:)=[];
b=size(a);
m=b(1);
n=b(2);
else
return
end
end
end
ans=a;
disp(ans)
You can try this one. Though I think there would be more concise way to do this

类别

Help CenterFile Exchange 中查找有关 Manual Performance Optimization 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by