How can i delete zeros of a Simulation Output?

1 visualizzazione (ultimi 30 giorni)
Pau Moreno
Pau Moreno il 18 Lug 2022
Risposto: Rebeka il 18 Lug 2022
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

Risposte (1)

Rebeka
Rebeka il 18 Lug 2022
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

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by