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 件のコメント
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
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)
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) %
% 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 件のコメント
Star Strider
2022 年 10 月 29 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!