How Do You Plot a Cosine Function with a Unit Step in MATLAB?

Click For Summary

Homework Help Overview

The discussion revolves around plotting the function cos(pi*n)*u(n) in MATLAB, where u(n) represents the unit step function. Participants are exploring how to implement this function correctly in their code.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • Participants attempt to define the unit step function and incorporate it into their MATLAB code. Questions arise regarding the implementation of the unit step function and its interaction with the cosine function.

Discussion Status

Some participants have shared their code attempts, while others are questioning specific aspects of the implementation, such as the role of the unit step function and its multiplication with the cosine function. There is an indication of progress as one participant mentions resolving their confusion.

Contextual Notes

There are mentions of potential misunderstandings regarding the unit step function's definition and its application in the context of the cosine function. The discussion reflects a collaborative effort to clarify these concepts.

cleopatra
Messages
45
Reaction score
0

Homework Statement



plot this function:
cos(pi*n)*u(n)



The Attempt at a Solution



n=0:1:10;
y=(n>=0);

x(n) = cos(pi()*n)*y

figure(1)
plot(y)
 
Physics news on Phys.org
cleopatra said:

Homework Statement



plot this function:
cos(pi*n)*u(n)

The Attempt at a Solution



n=0:1:10;
y=(n>=0);

x(n) = cos(pi()*n)*y

figure(1)
plot(y)

y(t>=0)=1; ?

This should work ..
t=-2:0.1:2;
x=cos(pi()*t); x(t<=0)=0;
plot(t,x);
 
Last edited:
I don´t get what x(t<=0)=0 does ?
And where do you multiply the unit step function?
You wrote x=cos(pi()*t); but I can´t see where u(t) is...
 
nevermind I got it. thanks
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
3
Views
2K
  • · Replies 40 ·
2
Replies
40
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K