Design an Input Signal
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2020-12-8
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 个评论
Image Analyst
2020-12-9
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!