Azzera filtri
Azzera filtri

Create a step in a graph

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 1 Apr 2023
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 Commento
Jórdan Venâncio Leite
Jórdan Venâncio Leite il 2 Apr 2023
I wanted the same way as my example, if possible.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by