Design an Input Signal
8 views (last 30 days)
Show older comments
Heraldo Tello
on 8 Dec 2020
Commented: Image Analyst
on 9 Dec 2020
Hello everyone,
I am tasked with creating a PRBS signal without using matlab shortcuts. Please see below. Once I create this PRBS signal I will run it through a p-code file and get an output. I am supposed to plot the system input vs time. It should look like the second picture.
Here is the code I have so far. I attempted to create a random signal and then run it through the transfer function.
My code is probably wrong so it is definitly not set in stone.
I do not know how to make the signal look almost digital. The example shows the input signal is either negative 1 or positive 1.
When I ran my code, I got two figures back. Please see below.
Any help or direction is greatly appreciated.
clear all
close all
clc
fs=300; % Sampling Frequency in Hz
t_final=1140; % Overall test duration in seconds
time=0:1/fs:t_final;
time=time';
fc=1000;
Wc=2*pi()*fc;
num=0.27;
den=[1 0.95*Wc 1.4*Wc^2 0.74*Wc^3 0.27*Wc^4];
G = tf(num,den)
x1=rand(length(time),1);
U = lsim(G,x1,time);
[Y]=MysterySystem(time,U);
figure
plot(time,Y,'linewidth',2)
xlabel('Time (seconds)')
ylabel('Output (dimensionless)')
title('Heraldo Tello - Experimental Testing of the Unknown System')
grid on
figure
plot(time,U)
0 Comments
Accepted Answer
Image Analyst
on 8 Dec 2020
You might look at fewer seconds so you can see the signal. Who told you to use that fs, fc, and t_final?
To get values of -1 or +1 only, you can do
signal = 2 * randi([0, 1], 1, numElements) - 1;
2 Comments
Image Analyst
on 9 Dec 2020
You're welcome. Thanks for Accepting.
time() is a built-in function. Since you're not supposed to use built-in function names as variable names, I suggest you call it times instead of time.
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown 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!