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.
6 次查看(过去 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!