フィルターのクリア

How can i delete zeros of a Simulation Output?

2 ビュー (過去 30 日間)
Pau Moreno
Pau Moreno 2022 年 7 月 18 日
回答済み: Rebeka 2022 年 7 月 18 日
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 Center および File ExchangeManual Performance Optimization についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by