フィルターのクリア

Hi. I am having issues with having my matlab get past the ifourier part of my code. It just continually runs and is stuck at that part. The bold is where my computer is stuck.

4 ビュー (過去 30 日間)
m = 10; % kg
k = 15; % N/m
b = 8;
syms x(t)
Dx = diff(x,t);
h_eqn = m*diff(x,t,2) + b*diff(x,t,1) + k*x;
Initial_conds = [x(0)==25 , Dx(0)==5];
h_solve = dsolve(h_eqn,Initial_conds);
t = linspace(0,10,1000);
ht = eval(h_solve);
syms t w
f_sym = exp(-2*t).*heaviside(t-3);
imp_sym= ht.*heaviside(t);
four_f_t = fourier(f_sym,t,w);
four_h_t = fourier(imp_sym,t,w);
X_w = four_h_t*four_f_t;
x_t = ifourier(X_w,w,t);
xt_vector = eval(x_t);
t = linspace(0,10,1000);
plot(t, xt_vector,'LineWidth',2)
  3 件のコメント
Justin Bryant
Justin Bryant 2022 年 10 月 31 日
Fourier Transforms: Declare t and ω symbolically. Redefine f(t) from part B as a symbolic
equation. Use the built in function fourier() to find the Fourier transform, F(ω), of f(t). Use the built
in function fourier() to find the Fourier transform, H(ω), of h(t).
(Hint: Use the symbolic h(t) equation that you got as your output from dsolve() in part A multiplied
by the unit step function as your input to fourier().)
In the Fourier domain, calculate X(ω) as a symbolic equation. Use the built in function ifourier() to
perform the inverse Fourier transform to get x(t) as a symbolic equation. Redefine your time vector
and use eval() to calculate x(t). Plot x(t) vs. t in the figure space indicated in the diagram above and
title the plot “Fourier Transform”
Paul
Paul 2022 年 10 月 31 日
Was dsolve() in part A used to solve an initial condition problem? If so, then all is fine, even though that doesn't make sense to me. But it only needs to make sense to you.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2022 年 10 月 29 日
It seems to work here —
m = 10; % kg
k = 15; % N/m
b = 8;
syms x(t)
Dx = diff(x,t);
h_eqn = m*diff(x,t,2) + b*diff(x,t,1) + k*x;
Initial_conds = [x(0)==25 , Dx(0)==5];
h_solve = dsolve(h_eqn,Initial_conds)
h_solve = 
t = linspace(0,10,1000);
% ht = eval(h_solve);
ht = h_solve;
syms t w
f_sym = exp(-2*t).*heaviside(t-3);
imp_sym= ht.*heaviside(t);
four_f_t = fourier(f_sym,t,w);
four_h_t = fourier(imp_sym,t,w);
X_w = four_h_t*four_f_t;
x_t = ifourier(X_w,w,t) %
x_t = 
% xt_vector = eval(x_t);
% t = linspace(0,10,1000);
% plot(t, xt_vector,'LineWidth',2)
figure
fplot(x_t, [0 10])
grid
xlabel('t')
ylabel('x\_t')
I eliminated the eval calls. (Perhaps that could be the problem?) I also replaced the plot call with the fplot call.
.
  2 件のコメント
Justin Bryant
Justin Bryant 2022 年 10 月 29 日
It worked. Thank you so much! I don't know why I was having a hard time.
Star Strider
Star Strider 2022 年 10 月 29 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by