Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to plot this signal?

9 visualizaciones (últimos 30 días)
mahmoud
mahmoud el 26 de Jul. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi there,
For this problem, I need to plot the function below. Its main idea to generate a random road profile by adding together sine waves of different frequencies and amplitudes in a chosen frequency range.
What I'm facing trouble with is the following:
1- How to express the sum of series in this equation
2- How to randomly generate the phase angle and how to implement it in the equation
3- What does "(K) the number of time samples" means and how to use it in substituting (tk) in the sin function.
Excuse me, I'm still a beginner in MATLAB so, I would be grateful for any help. Thanks in advance.
:
The reference:
Chapter 3
:
  3 comentarios
Ennio Condoleo
Ennio Condoleo el 27 de Jul. de 2017
I am supposing this is a homework, so I would not like to provide you the answer directly. Here you have only some hints: - define t as a vector by using "linspace" function (help linspace) - assign the constants as : "X = value"; - use "randn" or "rand" to generate a random number see the help)
I want to propose an example, if it is useful:
df = 0.5; & step freq Hz
fmin = 0.5; % min freq Hz
fmax = 10; % max freq HZ
f = fmin:df:fmax; % freq vect
ph = rand(length(f),1);
B = ...
U = ...
n1 = ...
c = 2*B*U^(n1-1);
% define all the variables required
Y = @(t,fj,pj) sqrt(c*df/fj^n1).*sin(2*pi*fj.*t+pj);
t = linspace(0,6,3042);
Yvalue = 0;
for j = 1:length(f)
Yvalue = Yvalue + Y(t,f(j),ph(j));
end
Try the code and edit it. I have written fastly!!!
mahmoud
mahmoud el 28 de Jul. de 2017
Hi Ennio Condoleo,
Thanks for your attention.
This is the code after editing. If you may, check it.
I have some notes or questions:
1- I don't fully understand the Function_Handle part but, Is its only function to make a functions of some arguments as in this case (t,fj,pj)?
2- This is the main problem I had before. There is always a conflict happens because of the dimension of the variables are not the same. For example (t 1x3042 double)(f 1x60 double)(ph 60x1 double).I am amazed that this time there was no error at all but, I can't figure out why ?
3- After plotting the signal with time, I need to use it in a Simulink model. So, is there a way to do that ?
df = 0.25; % step freq Hz
fmin = 0.25; % min freq Hz
fmax = 15; % max freq HZ
f = fmin:df:fmax; % freq vect
ph = 0 + ((2*pi)-0).*rand(1,length(f)); % a + (b - a) .* rand(Dim)
B = 3.14*(10^-6);
U = 20;
n1 = 2.5;
c = 2*B*U^(n1-1);
Y = @(t,fj,pj) sqrt(c*df/fj^n1).*sin(2*pi*fj.*t+pj);
t = linspace(0,12,3042);
Yvalue = 0;
for j = 1:length(f)
Yvalue = Yvalue + Y(t,f(j),ph(j));
end
plot(t,Yvalue)
I would be grateful for any help. Thanks in advance.

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by