フィルターのクリア

Create a step in a graph

1 回表示 (過去 30 日間)
Jórdan Venâncio Leite
Jórdan Venâncio Leite 2023 年 3 月 31 日
Hi all,
I already have a step up. i wish i had one down. how do i change my code?
aux1=70*1200;
aux2=70.2*1200;
for k=1:aux1
v_aux(k)=0.1;
end
for k=aux1:aux2
v_aux(k)=v_aux(k-1)+(0.3-0.2)/(360);
end
for k=aux2:240000
v_aux(k)=0.31;
end
for k=1:240000
v_aux(k)=v_aux(k)+(rand-0.5)*0.01;
end;
X2=v_aux';
Thanks in advance

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 4 月 1 日
In this exercise, no need to use a loop to obtain a step fcn. Way1 is using simple matrix operation:
aux1=70*1200;
aux2=70.2*1200;
X=0.1*ones(1,aux1);
X(70*1200:70.2*1200) =0.1;
X(70*1200:70.2*1200) = X((70*1200)-1:(70.2*1200)-1)+(0.3-0.2)/(360);
X(aux2:240000) = 0.31;
X(1:240000)=X(1:240000)+(rand(1,240000)-0.5)*0.01;
figure
plot(X)
%%
Way 2 is using heaviside() fcn:
syms x
figure
fplot(0.31*heaviside(x - .31), [0, 2]), shg
  1 件のコメント
Jórdan Venâncio Leite
Jórdan Venâncio Leite 2023 年 4 月 2 日
I wanted the same way as my example, if possible.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by