Error using odeset (line 231) Unrecognized property name 'mass_matrix_without_tld'. Error in my_ode_solver_without_tld (line 8) opts = odeset('mass_matrix_without_tld',@(t,y)
2 次查看(过去 30 天)
显示 更早的评论
function Y = mass_matrix_without_tld(t,y)
% Mass matrix function
Y = zeros(2,2);
Y(1,1) = 1;
Y(2,2) = 1;
end
clc;
clear all;
%% To run mass spring damper system
tspan = 0:0.1:20;
y = [0 0];
opts = odeset('mass_matrix_without_tld',@(t,y) mass_matrix_without_tld(t,y));
%% Solve using ode45
[tsol,ysol] = ode45(@(t,y)my_ode_without_tld(t,y), tspan, y, opts);
%% plotting
plot(tsol,ysol(:,1))
xlabel('time(sec)')
ylabel('displacement(m)')
grid on
title('Displacement response of structure')
figure
plot(tsol,ysol(:,2))
xlabel('time(sec)')
ylabel('velocity(m/s)')
grid on
title('Velocity response of structure')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!