How I summation graph ? I have photo exemple in this post.

I want sum graph 1 and graph 2 .How I write code. Thank you. I'm sorry for word.I'm not good english language.

 Accepted Answer

t=0:0.1:10
y1=10*sign(t-5)
y2=20*sign(t-5)
y=y1+y2
plot(t,y1,'r',t,y2,'g',t,y,'b')
If your signal is periodic
t=-20:0.01:20
y1=10*sign(abs(mod(t,10))-5)
y2=20*sign(abs(mod(t,10))-5)
y=y1+y2
plot(t,y1,'r',t,y2,'g',t,y,'b')

5 Comments

I don't understand.Can you explain me. Thank you.
for y1, If t-5 is negative the output will be 10 multiplied by -1, given by sign(t-5). If t-5 is positive ...
Now, based on this, if you want to do it with a for loop, try it.

Thank you very much.I tried it.It's ok.But i have question.If graph is not equal.How I should summation graph. Can summation? Thank you.

If it's another case, you have to figure it out. Just try to think a little.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!