Help Plotting a Signal Waveform

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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)