How to plot with if statement

How to plot with if statement :
I'm trying to plot this equation with if statement, but it didn't work
n=[0:20]
e(n+1)=sin(n+1)
a=2
Trial(n+1)=e(n+1)+a
k=1
for f=Trial(n+1)-k
if f<0,
alfa(n+1)=a
b=2
x=alfa(n+1)+b
else,
d=1
alfa(n+1)=a+d
b=2
c=4
x=alfa(n+1)+b+c
f=n+1
And how to plot (x vs alfa) ?

Antworten (1)

Cris LaPierre
Cris LaPierre am 2 Dez. 2020

0 Stimmen

I suggest going through MATLAB Onramp.
  • Ch 9 - plotting
  • Ch 13 - if statements, for loops

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020b

Gefragt:

am 2 Dez. 2020

Bearbeitet:

am 3 Dez. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by