Help Plotting a Signal Waveform

AI Thread Summary
To create a waveform in MATLAB using 1000 data points based on specified conditions, initialize a zero array of size 1000. Assign values to segments of the array according to the defined ranges: set the first 100 points to 1, the next 400 points (from 101 to 500) to 2, and the final 500 points (from 501 to 1000) to -5. Finally, use the plot function to visualize the waveform. This approach effectively generates the desired waveform based on the specified conditions.
Ugongorr
Messages
1
Reaction score
0
My mat lab skills are pretty low, basically i want to know how to make a waveform using 1000 points of data.

if the data is for example

y = 1 for 0<n<0.1
y = 2 for 0.1<n<0.5
y = -5 for 0.5 < n < 1

so how could i plot this waveform using 1000 points of data

cheers
 
Physics news on Phys.org
Try this and see what happens

y = zeros(1000);
for i=1:100
y(i) = 1;
end;
for i=101:500
y(i) = 2;
end;
for i=501:1000
y(i) = -5;
end;
plot(y)
 

Similar threads

Replies
8
Views
2K
Replies
1
Views
2K
Replies
9
Views
5K
Replies
2
Views
2K
Replies
4
Views
2K
Replies
1
Views
4K
Back
Top