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 views (last 30 days)
Show older comments
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 Comments
Paul
on 31 Oct 2022
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.
Answers (1)
Star Strider
on 29 Oct 2022
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 Comments
Star Strider
on 29 Oct 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!